Browse Source

Feature/neovim lsp refactor (#2)

* Refactor lsp neovim config

* Tweaked lsp installer path logic
master
Joshua Wolfe 5 months ago committed by GitHub
parent
commit
3deb98d7a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 48
      neovim/.config/nvim/lua/plugins/lsp-config.lua
  2. 1
      neovim/.config/nvim/viml/mappings.vim

48
neovim/.config/nvim/lua/plugins/lsp-config.lua

@ -1,9 +1,47 @@ @@ -1,9 +1,47 @@
local lsp = require('lspconfig')
local nvim_lsp = require('lspconfig')
local lsp_installer = require('nvim-lsp-installer')
lsp.tsserver.setup(coq.lsp_ensure_capabilities({}))
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
lsp.omnisharp.setup{
cmd = { "omnisharp", "--languageserver" , "--hostPID", tostring(vim.fn.getpid()) };
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>', opts)
end
local server_overrides = {
omnisharp = function(opts)
opts.cmd = { "omnisharp", "--languageserver" , "--hostPID", tostring(vim.fn.getpid()) }
end,
}
lsp.graphql.setup{}
lsp_installer.on_server_ready(function(server)
-- Specify the default options which we'll use to setup all servers
local opts = {
on_attach = on_attach,
}
if server_overrides[server.name] then
-- Enhance the default opts with the server-specific ones
server_overrides[server.name](opts)
end
server:setup(coq.lsp_ensure_capabilities(opts))
end)

1
neovim/.config/nvim/viml/mappings.vim

@ -33,7 +33,6 @@ nnoremap <leader>lx <cmd>lua require('telescope.builtin').lsp_code_actions(requi @@ -33,7 +33,6 @@ nnoremap <leader>lx <cmd>lua require('telescope.builtin').lsp_code_actions(requi
nnoremap <leader>lr <cmd>lua vim.lsp.buf.rename()<cr>
nnoremap <leader>lu <cmd>Telescope lsp_references<cr>
nnoremap <leader>li <cmd>Telescope lsp_implementations<cr>
nnoremap K <cmd>lua vim.lsp.buf.hover()<cr>
" Edit relative to current buffer
nnoremap <leader>e :e <C-R>=expand("%:h") . "/" <CR>

Loading…
Cancel
Save