Conditionally include lsp

This commit is contained in:
Alex Yatskov 2022-11-15 20:20:48 -08:00
parent 672c44d96a
commit 81cd9a6c79
2 changed files with 45 additions and 34 deletions

View File

@ -8,12 +8,20 @@ local capabilities = cmp_nvim_lsp.default_capabilities({snippetSupport = false})
-- nvim-lspconfig -- nvim-lspconfig
local nvim_lspconfig = require('lspconfig') local nvim_lspconfig = require('lspconfig')
nvim_lspconfig.clangd.setup({capabilities = capabilities}) if vim.fn.executable('clangd') then
nvim_lspconfig.gopls.setup({capabilities = capabilities}) nvim_lspconfig.clangd.setup({capabilities = capabilities})
nvim_lspconfig.jedi_language_server.setup({capabilities = capabilities}) end
nvim_lspconfig.rust_analyzer.setup({capabilities = capabilities}) if vim.fn.executable('gopls') then
nvim_lspconfig.tsserver.setup({capabilities = capabilities}) nvim_lspconfig.gopls.setup({capabilities = capabilities})
nvim_lspconfig.sumneko_lua.setup({ end
if vim.fn.executable('jedi-language-server') then
nvim_lspconfig.jedi_language_server.setup({capabilities = capabilities})
end
if vim.fn.executable('typescript-language-server') then
nvim_lspconfig.tsserver.setup({capabilities = capabilities})
end
if vim.fn.executable('lua-language-server') then
nvim_lspconfig.sumneko_lua.setup({
settings = { settings = {
Lua = { Lua = {
diagnostics = {globals = {'vim'}}, diagnostics = {globals = {'vim'}},
@ -22,7 +30,8 @@ nvim_lspconfig.sumneko_lua.setup({
workspace = {library = vim.api.nvim_get_runtime_file('', true)}, workspace = {library = vim.api.nvim_get_runtime_file('', true)},
}, },
}, },
}) })
end
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help) vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition) vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition)

View File

@ -1,12 +1,13 @@
-- fzf.vim -- fzf.vim
vim.g['$FZF_DEFAULT_COMMAND'] = 'ag --hidden --ignore .git -f -g "" 2> /dev/null' if vim.fn.executable('fzf') then
vim.g['$FZF_DEFAULT_COMMAND'] = 'ag --hidden --ignore .git -f -g "" 2> /dev/null'
vim.keymap.set('n', '<leader>fg', vim.cmd.GFiles) vim.keymap.set('n', '<leader>fg', vim.cmd.GFiles)
vim.keymap.set('n', '<leader>fh', vim.cmd.History) vim.keymap.set('n', '<leader>fh', vim.cmd.History)
vim.keymap.set('n', '<leader>fb', vim.cmd.Buffers) vim.keymap.set('n', '<leader>fb', vim.cmd.Buffers)
vim.keymap.set('n', '<leader>fl', vim.cmd.Lines) vim.keymap.set('n', '<leader>fl', vim.cmd.Lines)
vim.g.fzf_colors = { vim.g.fzf_colors = {
['bg'] = {'bg', 'Normal'}, ['bg'] = {'bg', 'Normal'},
['bg+'] = {'bg', 'CursorLine', 'CursorColumn'}, ['bg+'] = {'bg', 'CursorLine', 'CursorColumn'},
['border'] = {'fg', 'Ignore'}, ['border'] = {'fg', 'Ignore'},
@ -20,7 +21,8 @@ vim.g.fzf_colors = {
['pointer'] = {'fg', 'Exception'}, ['pointer'] = {'fg', 'Exception'},
['prompt'] = {'fg', 'Conditional'}, ['prompt'] = {'fg', 'Conditional'},
['spinner'] = {'fg', 'Label'}, ['spinner'] = {'fg', 'Label'},
} }
end
-- hflip.nvim -- hflip.nvim
vim.keymap.set('n', 'gfs', vim.cmd.HFlip) vim.keymap.set('n', 'gfs', vim.cmd.HFlip)