mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
fix: check if language server exists before using
This commit is contained in:
parent
597b11638f
commit
38883b3fc5
@ -1,6 +1,8 @@
|
|||||||
local api = vim.api
|
local api = vim.api
|
||||||
local lsp = vim.lsp
|
local lsp = vim.lsp
|
||||||
|
|
||||||
|
local utils = require("utils")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.show_line_diagnostics()
|
function M.show_line_diagnostics()
|
||||||
@ -73,6 +75,7 @@ capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|||||||
|
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require("lspconfig")
|
||||||
|
|
||||||
|
if utils.executable('pylsp') then
|
||||||
lspconfig.pylsp.setup({
|
lspconfig.pylsp.setup({
|
||||||
on_attach = custom_attach,
|
on_attach = custom_attach,
|
||||||
settings = {
|
settings = {
|
||||||
@ -92,12 +95,20 @@ lspconfig.pylsp.setup({
|
|||||||
},
|
},
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
})
|
})
|
||||||
|
else
|
||||||
|
vim.notify("pylsp not found!", 'warn', {title = 'Nvim-config'})
|
||||||
|
end
|
||||||
|
|
||||||
|
-- if utils.executable('pyright') then
|
||||||
-- lspconfig.pyright.setup{
|
-- lspconfig.pyright.setup{
|
||||||
-- on_attach = custom_attach,
|
-- on_attach = custom_attach,
|
||||||
-- capabilities = capabilities
|
-- capabilities = capabilities
|
||||||
-- }
|
-- }
|
||||||
|
-- else
|
||||||
|
-- vim.notify("pyright not found!", 'warn', {title = 'Nvim-config'})
|
||||||
|
-- end
|
||||||
|
|
||||||
|
if utils.executable('clangd') then
|
||||||
lspconfig.clangd.setup({
|
lspconfig.clangd.setup({
|
||||||
on_attach = custom_attach,
|
on_attach = custom_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
@ -106,8 +117,12 @@ lspconfig.clangd.setup({
|
|||||||
debounce_text_changes = 500,
|
debounce_text_changes = 500,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
else
|
||||||
|
vim.notify("clangd not found!", 'warn', {title = 'Nvim-config'})
|
||||||
|
end
|
||||||
|
|
||||||
-- set up vim-language-server
|
-- set up vim-language-server
|
||||||
|
if utils.executable('vim-language-server') then
|
||||||
lspconfig.vimls.setup({
|
lspconfig.vimls.setup({
|
||||||
on_attach = custom_attach,
|
on_attach = custom_attach,
|
||||||
flags = {
|
flags = {
|
||||||
@ -115,12 +130,17 @@ lspconfig.vimls.setup({
|
|||||||
},
|
},
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
})
|
})
|
||||||
|
else
|
||||||
|
vim.notify("vim-language-server not found!", 'warn', {title = 'Nvim-config'})
|
||||||
|
end
|
||||||
|
|
||||||
-- set up bash-language-server
|
-- set up bash-language-server
|
||||||
|
if utils.executable('bash-language-server') then
|
||||||
lspconfig.bashls.setup({
|
lspconfig.bashls.setup({
|
||||||
on_attach = custom_attach,
|
on_attach = custom_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
|
||||||
local sumneko_binary_path = vim.fn.exepath("lua-language-server")
|
local sumneko_binary_path = vim.fn.exepath("lua-language-server")
|
||||||
if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then
|
if vim.g.is_mac or vim.g.is_linux and sumneko_binary_path ~= "" then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user