diff options
Diffstat (limited to '.config/nvim/lua/lsp.lua')
| -rw-r--r-- | .config/nvim/lua/lsp.lua | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua deleted file mode 100644 index 87c00ed..0000000 --- a/.config/nvim/lua/lsp.lua +++ /dev/null @@ -1,97 +0,0 @@ --- ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ --- ┃ ╻ ┏━┓┏━┓ ┏━╸┏━┓┏┓╻┏━╸╻┏━╸ ┃ --- ┃ ┃ ┗━┓┣━┛ ┃ ┃ ┃┃┗┫┣╸ ┃┃╺┓ ┃ --- ┃ ┗━╸┗━┛╹ ┗━╸┗━┛╹ ╹╹ ╹┗━┛ ┃ --- ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ - -vim.diagnostic.config({ - virtual_text = { - prefix = "" - } -}) - -vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('UserLspConfig', {}), - callback = function(ev) - - vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' - - local opts = { buffer = ev.buf } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) - vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts) - vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts) - vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts) - vim.keymap.set('n', '<space>wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, opts) - vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts) - vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts) - vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) - vim.keymap.set('n', '<space>f', function() - vim.lsp.buf.format { async = true } - end, opts) - vim.keymap.set('n', '<space>d', vim.diagnostic.open_float, opts) - vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) - vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) - vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist) - end, -}) - - -local capabilities = require("cmp_nvim_lsp").default_capabilities() - -local lspconfig = require('lspconfig') - -local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver' } -for _, lsp in ipairs(servers) do - lspconfig[lsp].setup { - capabilities = capabilities, - } -end - -lspconfig.lua_ls.setup { - on_init = function(client) - local path = client.workspace_folders[1].name - if not vim.loop.fs_stat(path..'/.luarc.json') and not vim.loop.fs_stat(path..'/.luarc.jsonc') then - client.config.settings = vim.tbl_deep_extend('force', client.config.settings, { - Lua = { - runtime = { - -- Tell the language server which version of Lua you're using - -- (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT' - }, - -- Make the server aware of Neovim runtime files - workspace = { - checkThirdParty = false, - library = { - vim.env.VIMRUNTIME - -- "${3rd}/luv/library" - -- "${3rd}/busted/library", - } - -- or pull in all of 'runtimepath'. NOTE: this is a lot slower - -- library = vim.api.nvim_get_runtime_file("", true) - } - } - }) - - client.notify("workspace/didChangeConfiguration", { settings = client.config.settings }) - end - return true - end -} - -vim.api.nvim_create_autocmd("InsertLeave", { - callback = function() - if - require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] - and not require("luasnip").session.jump_active - then - require("luasnip").unlink_current() - end - end, -}) - |