From 81cd9a6c796403b8a8105fad193969bcd857ddd0 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Tue, 15 Nov 2022 20:20:48 -0800 Subject: [PATCH] Conditionally include lsp --- lua/lsp.lua | 37 +++++++++++++++++++++++-------------- lua/plugins.lua | 42 ++++++++++++++++++++++-------------------- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index 78cf134..6785e4d 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -8,21 +8,30 @@ local capabilities = cmp_nvim_lsp.default_capabilities({snippetSupport = false}) -- nvim-lspconfig local nvim_lspconfig = require('lspconfig') -nvim_lspconfig.clangd.setup({capabilities = capabilities}) -nvim_lspconfig.gopls.setup({capabilities = capabilities}) -nvim_lspconfig.jedi_language_server.setup({capabilities = capabilities}) -nvim_lspconfig.rust_analyzer.setup({capabilities = capabilities}) -nvim_lspconfig.tsserver.setup({capabilities = capabilities}) -nvim_lspconfig.sumneko_lua.setup({ - settings = { - Lua = { - diagnostics = {globals = {'vim'}}, - runtime = {version = 'LuaJIT'}, - telemetry = {enable = false}, - workspace = {library = vim.api.nvim_get_runtime_file('', true)}, +if vim.fn.executable('clangd') then + nvim_lspconfig.clangd.setup({capabilities = capabilities}) +end +if vim.fn.executable('gopls') then + nvim_lspconfig.gopls.setup({capabilities = capabilities}) +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 = { + Lua = { + diagnostics = {globals = {'vim'}}, + runtime = {version = 'LuaJIT'}, + telemetry = {enable = false}, + workspace = {library = vim.api.nvim_get_runtime_file('', true)}, + }, }, - }, -}) + }) +end vim.keymap.set('n', '', vim.lsp.buf.signature_help) vim.keymap.set('n', 'D', vim.lsp.buf.type_definition) diff --git a/lua/plugins.lua b/lua/plugins.lua index 84853e5..6e2d86c 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,26 +1,28 @@ -- 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', 'fg', vim.cmd.GFiles) -vim.keymap.set('n', 'fh', vim.cmd.History) -vim.keymap.set('n', 'fb', vim.cmd.Buffers) -vim.keymap.set('n', 'fl', vim.cmd.Lines) + vim.keymap.set('n', 'fg', vim.cmd.GFiles) + vim.keymap.set('n', 'fh', vim.cmd.History) + vim.keymap.set('n', 'fb', vim.cmd.Buffers) + vim.keymap.set('n', 'fl', vim.cmd.Lines) -vim.g.fzf_colors = { - ['bg'] = {'bg', 'Normal'}, - ['bg+'] = {'bg', 'CursorLine', 'CursorColumn'}, - ['border'] = {'fg', 'Ignore'}, - ['fg'] = {'fg', 'Normal'}, - ['fg+'] = {'fg', 'CursorLine', 'CursorColumn', 'Normal'}, - ['header'] = {'fg', 'Comment'}, - ['hl'] = {'fg', 'Comment'}, - ['hl+'] = {'fg', 'Statement'}, - ['info'] = {'fg', 'PreProc'}, - ['marker'] = {'fg', 'Keyword'}, - ['pointer'] = {'fg', 'Exception'}, - ['prompt'] = {'fg', 'Conditional'}, - ['spinner'] = {'fg', 'Label'}, -} + vim.g.fzf_colors = { + ['bg'] = {'bg', 'Normal'}, + ['bg+'] = {'bg', 'CursorLine', 'CursorColumn'}, + ['border'] = {'fg', 'Ignore'}, + ['fg'] = {'fg', 'Normal'}, + ['fg+'] = {'fg', 'CursorLine', 'CursorColumn', 'Normal'}, + ['header'] = {'fg', 'Comment'}, + ['hl'] = {'fg', 'Comment'}, + ['hl+'] = {'fg', 'Statement'}, + ['info'] = {'fg', 'PreProc'}, + ['marker'] = {'fg', 'Keyword'}, + ['pointer'] = {'fg', 'Exception'}, + ['prompt'] = {'fg', 'Conditional'}, + ['spinner'] = {'fg', 'Label'}, + } +end -- hflip.nvim vim.keymap.set('n', 'gfs', vim.cmd.HFlip)