added new server lua file
This commit is contained in:
170
lua/plugins/lsp/server.lua
Normal file
170
lua/plugins/lsp/server.lua
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
local efm_setup = function(lspconfig, capabilities, on_attach)
|
||||||
|
local prettier = require('efmls-configs.formatters.prettier')
|
||||||
|
local stylua = require('efmls-configs.formatters.stylua')
|
||||||
|
local gersemi = require('efmls-configs.formatters.gersemi')
|
||||||
|
local black = require('efmls-configs.formatters.black')
|
||||||
|
local isort = require('efmls-configs.formatters.isort')
|
||||||
|
local cmake_lint = require('efmls-configs.linters.cmake_lint')
|
||||||
|
local flake8 = require('efmls-configs.linters.flake8')
|
||||||
|
local languages = {
|
||||||
|
lua = { stylua },
|
||||||
|
markdown = { prettier },
|
||||||
|
cmake = { gersemi, cmake_lint },
|
||||||
|
python = { isort, black, flake8 },
|
||||||
|
}
|
||||||
|
|
||||||
|
local efmls_config = {
|
||||||
|
-- filetypes = vim.tbl_keys(languages),
|
||||||
|
settings = {
|
||||||
|
rootMarkers = { '.git/' },
|
||||||
|
languages = languages,
|
||||||
|
},
|
||||||
|
init_options = {
|
||||||
|
documentFormatting = true,
|
||||||
|
documentRangeFormatting = true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
require('lspconfig').efm.setup(vim.tbl_extend('force', efmls_config, {
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
|
M.setup_server = function(lspconfig, capabilities, on_attach)
|
||||||
|
-- lspconfig['pyright'].setup {
|
||||||
|
-- capabilities = capabilities,
|
||||||
|
-- on_attach = on_attach,
|
||||||
|
-- }
|
||||||
|
|
||||||
|
lspconfig['basedpyright'].setup({
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
settings = {
|
||||||
|
basedpyright = {
|
||||||
|
typeCheckingMode = 'standard',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
lspconfig['groovyls'].setup({
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- lspconfig['cmake'].setup {
|
||||||
|
-- capabilities = capabilities,
|
||||||
|
-- on_attach = on_attach,
|
||||||
|
-- }
|
||||||
|
|
||||||
|
local clangd_capabilities = capabilities
|
||||||
|
clangd_capabilities.textDocument.semanticHighlighting = true
|
||||||
|
clangd_capabilities.offsetEncoding = { 'utf-16' }
|
||||||
|
lspconfig['clangd'].setup({
|
||||||
|
capabilities = clangd_capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
cmd = {
|
||||||
|
'clangd',
|
||||||
|
'--compile-commands-dir=build_nvim',
|
||||||
|
'--query-driver',
|
||||||
|
'/opt/cortex-a78-2022.08-gcc12.1-linux5.15/bin/aarch64-linux-gnu-g*',
|
||||||
|
'--clang-tidy',
|
||||||
|
'--background-index',
|
||||||
|
'--use-dirty-headers',
|
||||||
|
'--completion-style=detailed',
|
||||||
|
},
|
||||||
|
root_dir = lspconfig.util.root_pattern('.clangd', '.clang-tidy', '.clang-format', 'compile_flags.txt', 'configure.ac', '.git', 'build_nvim'),
|
||||||
|
})
|
||||||
|
|
||||||
|
require('clangd_extensions').setup({
|
||||||
|
extensions = {
|
||||||
|
inlay_hints = {
|
||||||
|
-- Only show inlay hints for the current line
|
||||||
|
only_current_line = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
lspconfig['jsonls'].setup({
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- lspconfig['rust_analyzer'].setup {
|
||||||
|
-- capabilities = capabilities,
|
||||||
|
-- on_attach = on_attach,
|
||||||
|
-- }
|
||||||
|
|
||||||
|
lspconfig['lua_ls'].setup({
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
workspace = {
|
||||||
|
checkThirdParty = false,
|
||||||
|
},
|
||||||
|
completion = {
|
||||||
|
callSnippet = 'Replace',
|
||||||
|
},
|
||||||
|
-- Do not send telemetry data containing a randomized but unique identifier
|
||||||
|
telemetry = {
|
||||||
|
enable = false,
|
||||||
|
},
|
||||||
|
format = {
|
||||||
|
enable = true,
|
||||||
|
defaultConfig = {
|
||||||
|
indent_style = 'space',
|
||||||
|
indent_size = '2',
|
||||||
|
quote_style = 'single',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
lspconfig['dockerls'].setup({
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
})
|
||||||
|
|
||||||
|
lspconfig['markdown_oxide'].setup({
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- lspconfig['marksman'].setup {
|
||||||
|
-- capabilities = capabilities,
|
||||||
|
-- on_attach = on_attach,
|
||||||
|
-- }
|
||||||
|
|
||||||
|
lspconfig['yamlls'].setup({
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
settings = {
|
||||||
|
yaml = {
|
||||||
|
validate = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
local configs = require('lspconfig.configs')
|
||||||
|
if not configs.neocmake then
|
||||||
|
configs.neocmake = {
|
||||||
|
default_config = {
|
||||||
|
cmd = { 'neocmakelsp', '--stdio' },
|
||||||
|
filetypes = { 'cmake' },
|
||||||
|
root_dir = function(fname)
|
||||||
|
return lspconfig.util.find_git_ancestor(fname)
|
||||||
|
end,
|
||||||
|
single_file_support = true, -- suggested
|
||||||
|
on_attach = on_attach, -- on_attach is the on_attach function you defined
|
||||||
|
},
|
||||||
|
}
|
||||||
|
lspconfig.neocmake.setup({})
|
||||||
|
end
|
||||||
|
|
||||||
|
efm_setup(lspconfig, capabilities, on_attach)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
@ -99,38 +99,6 @@ local on_attach = function(client, bufnr)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local efm_setup = function(capabilities)
|
|
||||||
local prettier = require('efmls-configs.formatters.prettier')
|
|
||||||
local stylua = require('efmls-configs.formatters.stylua')
|
|
||||||
local gersemi = require('efmls-configs.formatters.gersemi')
|
|
||||||
local black = require('efmls-configs.formatters.black')
|
|
||||||
local isort = require('efmls-configs.formatters.isort')
|
|
||||||
local cmake_lint = require('efmls-configs.linters.cmake_lint')
|
|
||||||
local flake8 = require('efmls-configs.linters.flake8')
|
|
||||||
local languages = {
|
|
||||||
lua = { stylua },
|
|
||||||
markdown = { prettier },
|
|
||||||
cmake = { gersemi, cmake_lint },
|
|
||||||
python = { isort, black, flake8 },
|
|
||||||
}
|
|
||||||
|
|
||||||
local efmls_config = {
|
|
||||||
-- filetypes = vim.tbl_keys(languages),
|
|
||||||
settings = {
|
|
||||||
rootMarkers = { '.git/' },
|
|
||||||
languages = languages,
|
|
||||||
},
|
|
||||||
init_options = {
|
|
||||||
documentFormatting = true,
|
|
||||||
documentRangeFormatting = true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
require('lspconfig').efm.setup(vim.tbl_extend('force', efmls_config, {
|
|
||||||
on_attach = on_attach,
|
|
||||||
capabilities = capabilities,
|
|
||||||
}))
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'neovim/nvim-lspconfig',
|
'neovim/nvim-lspconfig',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
@ -178,139 +146,7 @@ return {
|
|||||||
vim.diagnostic.open_float({ focusable = false, width = 80 })
|
vim.diagnostic.open_float({ focusable = false, width = 80 })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- lspconfig['pyright'].setup {
|
require('plugins.lsp.server').setup_server(lspconfig, capabilities, on_attach)
|
||||||
-- capabilities = capabilities,
|
|
||||||
-- on_attach = on_attach,
|
|
||||||
-- }
|
|
||||||
|
|
||||||
lspconfig['basedpyright'].setup({
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
settings = {
|
|
||||||
basedpyright = {
|
|
||||||
typeCheckingMode = 'standard',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
lspconfig['groovyls'].setup({
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- lspconfig['cmake'].setup {
|
|
||||||
-- capabilities = capabilities,
|
|
||||||
-- on_attach = on_attach,
|
|
||||||
-- }
|
|
||||||
|
|
||||||
local configs = require('lspconfig.configs')
|
|
||||||
if not configs.neocmake then
|
|
||||||
configs.neocmake = {
|
|
||||||
default_config = {
|
|
||||||
cmd = { 'neocmakelsp', '--stdio' },
|
|
||||||
filetypes = { 'cmake' },
|
|
||||||
root_dir = function(fname)
|
|
||||||
return lspconfig.util.find_git_ancestor(fname)
|
|
||||||
end,
|
|
||||||
single_file_support = true, -- suggested
|
|
||||||
on_attach = on_attach, -- on_attach is the on_attach function you defined
|
|
||||||
},
|
|
||||||
}
|
|
||||||
lspconfig.neocmake.setup({})
|
|
||||||
end
|
|
||||||
|
|
||||||
local clangd_capabilities = capabilities
|
|
||||||
clangd_capabilities.textDocument.semanticHighlighting = true
|
|
||||||
clangd_capabilities.offsetEncoding = { 'utf-16' }
|
|
||||||
lspconfig['clangd'].setup({
|
|
||||||
capabilities = clangd_capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
cmd = {
|
|
||||||
'clangd',
|
|
||||||
'--compile-commands-dir=build_nvim',
|
|
||||||
'--query-driver',
|
|
||||||
'/opt/cortex-a78-2022.08-gcc12.1-linux5.15/bin/aarch64-linux-gnu-g*',
|
|
||||||
'--clang-tidy',
|
|
||||||
'--background-index',
|
|
||||||
'--use-dirty-headers',
|
|
||||||
'--completion-style=detailed',
|
|
||||||
},
|
|
||||||
root_dir = lspconfig.util.root_pattern('.clangd', '.clang-tidy', '.clang-format', 'compile_flags.txt',
|
|
||||||
'configure.ac', '.git', 'build_nvim'),
|
|
||||||
})
|
|
||||||
|
|
||||||
require('clangd_extensions').setup({
|
|
||||||
extensions = {
|
|
||||||
inlay_hints = {
|
|
||||||
-- Only show inlay hints for the current line
|
|
||||||
only_current_line = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
lspconfig['jsonls'].setup({
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- lspconfig['rust_analyzer'].setup {
|
|
||||||
-- capabilities = capabilities,
|
|
||||||
-- on_attach = on_attach,
|
|
||||||
-- }
|
|
||||||
|
|
||||||
lspconfig['lua_ls'].setup({
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
settings = {
|
|
||||||
Lua = {
|
|
||||||
workspace = {
|
|
||||||
checkThirdParty = false,
|
|
||||||
},
|
|
||||||
completion = {
|
|
||||||
callSnippet = 'Replace',
|
|
||||||
},
|
|
||||||
-- Do not send telemetry data containing a randomized but unique identifier
|
|
||||||
telemetry = {
|
|
||||||
enable = false,
|
|
||||||
},
|
|
||||||
format = {
|
|
||||||
enable = true,
|
|
||||||
defaultConfig = {
|
|
||||||
indent_style = 'space',
|
|
||||||
indent_size = '2',
|
|
||||||
quote_style = 'single',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
lspconfig['dockerls'].setup({
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
})
|
|
||||||
|
|
||||||
lspconfig['markdown_oxide'].setup({
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- lspconfig['marksman'].setup {
|
|
||||||
-- capabilities = capabilities,
|
|
||||||
-- on_attach = on_attach,
|
|
||||||
-- }
|
|
||||||
|
|
||||||
lspconfig['yamlls'].setup({
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
settings = {
|
|
||||||
yaml = {
|
|
||||||
validate = true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
efm_setup(capabilities)
|
|
||||||
end,
|
end,
|
||||||
event = 'VeryLazy',
|
event = 'VeryLazy',
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user