repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

fine tuning of lsp jungle

9ef20475afd2c5f383e883a6162e77886b191763

Oliver Krylow <o.krylow@isp-insoft.de> ·

unsigned

Browse filesCompare with HEAD

Changed files (3)

neovim/lua/autocommand.lua

Modified
1 1 -- This function creates a custom API over autocommands in nvim.
2 2 -- Since an official API is not present yet, I simply stole one from norcalli.
3 3 -- groups: a map of group name to list of vimscript commands (table of string), or a single vimscript command (string).
4 -return function(groups)
5 - for name, commands in pairs(groups) do
4 +return function(autocmd_groups)
5 + for name, commands in pairs(autocmd_groups) do
6 6 -- wrap autocommands in a group and..
7 7 vim.cmd('augroup ' .. name)
8 8 -- ... undefine the groups commands, so that they become idempotent.

neovim/lua/lsp.lua

Modified
4 4 -- This function configures all the LSP clients that i might care about.
5 5 -- It is expected to be called in the 'config' step of the 'lspconfig' plugin.
6 6 -- autocommand: function, that can create autocmds
7 7 return function()
8 8 local integrate_into_neovim = function(client, buffer_number)
9 9 print("LSP " .. client.name .. " [" .. client.id .. "] " .. "started.")
10 - local chain_complete_list = {
11 - default = {
12 - { complete_items = { "lsp", "snippet" } },
13 - { complete_items = { "path" }, triggered_only = { "/" } },
14 - { complete_items = { "buffers" } },
15 - },
16 - string = {
17 - { complete_items = { "path" }, triggered_only = { "/" } },
18 - },
19 - comment = {},
20 - }
22 - require("completion").on_attach({
23 - sorting = "length",
24 - enable_auto_popup = false,
25 - chain_complete_list = chain_complete_list,
26 - })
11 + -- enable lsp-powered auto-completion
12 + -- FIXME: I cannot seem to configure this plugin to my liking.
13 + require("completion").on_attach()
14 + -- adds icons into the completion ui
15 + require"lspkind".init()
28 17 -- hook lsp into vim autocomplete in insert mode
29 18 vim.api.nvim_buf_set_option(buffer_number, "omnifunc", "v:lua.vim.lsp.omnifunc")
32 21 map("n", "<LEADER>gD", "<CMD>lua vim.lsp.buf.declaration()<CR>")
33 22 map("n", "<LEADER>gd", "<CMD>lua vim.lsp.buf.definition()<CR>")
34 - map("n", "<LEADER>K", "<CMD>lua vim.lsp.buf.hover()<CR>")
35 23 map("n", "<LEADER>gr", "<CMD>lua vim.lsp.buf.references()<CR>")
36 - map("n", "<LEADER>gs", "<CMD>lua vim.lsp.buf.signature_help()<CR>")
37 24 map("n", "<LEADER>gi", "<CMD>lua vim.lsp.buf.implementation()<CR>")
38 25 map("n", "<LEADER>gt", "<CMD>lua vim.lsp.buf.type_definition()<CR>")
39 26 map("n", "<LEADER>gw", "<CMD>lua vim.lsp.buf.document_symbol()<CR>")
40 27 map("n", "<LEADER>gW", "<CMD>lua vim.lsp.buf.workspace_symbol()<CR>")
41 29 map("n", "<LEADER>ah", "<CMD>lua vim.lsp.buf.hover()<CR>")
30 + map("n", "<LEADER>as", "<CMD>lua vim.lsp.buf.signature_help()<CR>")
42 31 map("n", "<LEADER>af", "<CMD>lua vim.lsp.buf.code_action()<CR>")
43 32 map("n", "<LEADER>ar", "<CMD>lua vim.lsp.buf.rename()<CR>")
44 - map("n", "<LEADER>=", "<CMD>lua vim.lsp.buf.formatting()<CR>")
33 + map("n", "<LEADER>a=", "<CMD>lua vim.lsp.buf.formatting()<CR>")
45 34 map("n", "<LEADER>ai", "<CMD>lua vim.lsp.buf.incoming_calls()<CR>")
46 35 map("n", "<LEADER>ao", "<CMD>lua vim.lsp.buf.outgoing_calls()<CR>")
120 110 -- Markdown Notes (Zettelkasten) LSP
121 111 lsp.zeta_note.setup({
122 112 on_attach = integrate_into_neovim,

neovim/lua/plugins.lua

Modified
95 95 -- NVIM API for defining color schemes
96 - -- TODO: when profiling, this plugins loading times are high
97 - -- maybe the cause is that it loads a bunch of files
98 - -- should those be merged into one file?
99 96 use({
100 97 "tjdevries/colorbuddy.vim",
101 98 config = function()
142 139 refactor = {
143 140 highlight_definitions = { enable = true },
144 141 smart_rename = { enable = true, keymaps = { smart_rename = "<LEADER>r" } },
145 - navigation = { enable = true, keymaps = { goto_next_usage = "<a-.>", goto_previous_usage = "<a-,>" } },
142 + navigation = {
143 + enable = true,
144 + keymaps = { goto_next_usage = "<a-.>", goto_previous_usage = "<a-,>" },
145 + },
205 205 -- This will configure all LSPs not only Null-ls.
206 206 -- But because Null-ls depends on lspconfig, we have to delay this
207 207 require("lsp")()
208 + -- overwrite default action handlers with cuter ones
209 + vim.lsp.handlers["textDocument/codeAction"] = require("lsputil.codeAction").code_action_handler
210 + vim.lsp.handlers["textDocument/references"] = require("lsputil.locations").references_handler
211 + vim.lsp.handlers["textDocument/definition"] = require("lsputil.locations").definition_handler
212 + vim.lsp.handlers["textDocument/declaration"] = require("lsputil.locations").declaration_handler
213 + vim.lsp.handlers["textDocument/typeDefinition"] = require("lsputil.locations").typeDefinition_handler
214 + vim.lsp.handlers["textDocument/implementation"] = require("lsputil.locations").implementation_handler
215 + vim.lsp.handlers["textDocument/documentSymbol"] = require("lsputil.symbols").document_handler
216 + vim.lsp.handlers["workspace/symbol"] = require("lsputil.symbols").workspace_handler
209 218 requires = {
210 219 -- extensions to the std lib
213 222 "neovim/nvim-lspconfig",
214 223 -- Completions support, that integrates advanced nvim features (LSP+treesitter)
215 224 "nvim-lua/completion-nvim",
225 + -- Icons for completion UI
226 + "onsails/lspkind-nvim",
227 + -- dependency of nvim-lsputils
228 + "RishabhRD/popfix",
229 + -- collection of better handlers for lsp actions.
230 + -- e.g. puts selection of code actions into floating window
231 + "RishabhRD/nvim-lsputils",
251 267 opt = true,
252 268 command = "VBox",
271 + -- convenient lua abstraction over the nvim keymap function
272 + -- TODO: use it throughout the code
273 + use("Iron-E/nvim-cartographer")
275 + -- automatically size splits reasonably
276 + use("beauwilliams/focus.nvim")
256 279 -- the plugin module always delegates to packer, ensuring that at all times init configures packer correctly