2021-11-22 18:45:07 +01:00
|
|
|
local lsp = require "lspconfig"
|
2021-08-12 13:12:30 +02:00
|
|
|
local lsp_status = require("lsp-status")
|
|
|
|
|
2022-01-14 16:14:57 +01:00
|
|
|
_G.lsp_organize_imports = function()
|
|
|
|
local params = {
|
|
|
|
command = "_typescript.organizeImports",
|
|
|
|
arguments = {vim.api.nvim_buf_get_name(0)},
|
|
|
|
title = ""
|
|
|
|
}
|
|
|
|
vim.lsp.buf.execute_command(params)
|
|
|
|
end
|
|
|
|
|
2021-08-12 13:12:30 +02:00
|
|
|
-- function to attach completion when setting up lsp
|
2021-11-22 18:45:07 +01:00
|
|
|
local function on_attach()
|
2022-02-02 14:28:36 +01:00
|
|
|
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
|
|
|
vim.cmd("command! LspOrganize lua lsp_organize_imports()")
|
|
|
|
vim.api.nvim_buf_map(bufnr, "n", "gs", ":LspOrganize<CR>", {silent = true})
|
2021-08-12 13:12:30 +02:00
|
|
|
end
|
2021-09-06 13:29:42 +02:00
|
|
|
|
|
|
|
local runtime_path = vim.split(package.path, ";")
|
|
|
|
table.insert(runtime_path, "lua/?.lua")
|
|
|
|
table.insert(runtime_path, "lua/?/init.lua")
|
|
|
|
|
2022-02-03 12:34:50 +01:00
|
|
|
print(runtime_path)
|
|
|
|
|
|
|
|
require "lspconfig".sumneko_lua.setup {
|
2022-01-26 20:42:58 +01:00
|
|
|
settings = {
|
|
|
|
Lua = {
|
|
|
|
runtime = {
|
|
|
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
|
|
|
version = "LuaJIT",
|
|
|
|
-- Setup your lua path
|
|
|
|
path = runtime_path
|
|
|
|
},
|
|
|
|
diagnostics = {
|
|
|
|
-- Get the language server to recognize the `vim` global
|
2022-02-03 12:34:50 +01:00
|
|
|
globals = {"vim"}
|
2022-01-26 20:42:58 +01:00
|
|
|
},
|
|
|
|
workspace = {
|
|
|
|
-- Make the server aware of Neovim runtime files
|
|
|
|
library = vim.api.nvim_get_runtime_file("", true)
|
|
|
|
},
|
|
|
|
-- Do not send telemetry data containing a randomized but unique identifier
|
|
|
|
telemetry = {
|
|
|
|
enable = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-06 13:29:42 +02:00
|
|
|
}
|
|
|
|
|
2021-11-26 16:40:32 +01:00
|
|
|
-- Ltex Language Server
|
2022-03-01 23:25:44 +01:00
|
|
|
require("grammar-guard").init()
|
|
|
|
-- setup LSP config
|
|
|
|
require("lspconfig").grammar_guard.setup(
|
|
|
|
{
|
|
|
|
cmd = {vim.fn.expand("~/.local/share/nvim/lsp_servers/ltex/ltex-ls/bin/ltex-ls")},
|
|
|
|
settings = {
|
|
|
|
ltex = {
|
|
|
|
enabled = {"latex", "tex", "bib", "markdown"},
|
|
|
|
language = "de",
|
|
|
|
diagnosticSeverity = "information",
|
|
|
|
additionalRules = {
|
|
|
|
enablePickyRules = true,
|
|
|
|
motherTongue = "de"
|
|
|
|
},
|
|
|
|
dictionary = {},
|
|
|
|
disabledRules = {},
|
|
|
|
hiddenFalsePositives = {}
|
|
|
|
}
|
2022-02-03 12:34:50 +01:00
|
|
|
}
|
2022-02-02 14:28:36 +01:00
|
|
|
}
|
2022-03-01 23:25:44 +01:00
|
|
|
)
|
2021-09-06 13:29:42 +02:00
|
|
|
|
2021-11-26 16:40:32 +01:00
|
|
|
-- Go Language Server
|
2021-11-22 18:45:07 +01:00
|
|
|
lsp.gopls.setup {
|
2022-01-26 20:42:58 +01:00
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = lsp_status.capabilities
|
2021-08-12 13:12:30 +02:00
|
|
|
}
|
2021-09-06 13:29:42 +02:00
|
|
|
|
2021-09-12 16:35:38 +02:00
|
|
|
-- Html Setup
|
2021-11-22 18:45:07 +01:00
|
|
|
lsp.html.setup {
|
2022-01-26 20:42:58 +01:00
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = lsp_status.capabilities,
|
|
|
|
filetypes = {"html"}
|
2021-09-12 16:35:38 +02:00
|
|
|
}
|
|
|
|
|
2021-09-06 13:29:42 +02:00
|
|
|
-- Svelte Language Server
|
2021-11-22 18:45:07 +01:00
|
|
|
lsp.svelte.setup {
|
2022-01-26 20:42:58 +01:00
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = lsp_status.capabilities
|
2021-09-06 13:29:42 +02:00
|
|
|
}
|
|
|
|
|
2022-02-02 14:28:36 +01:00
|
|
|
local function organize_imports()
|
|
|
|
local params = {
|
|
|
|
command = "_typescript.organizeImports",
|
|
|
|
arguments = {vim.api.nvim_buf_get_name(0)},
|
|
|
|
title = ""
|
|
|
|
}
|
|
|
|
vim.lsp.buf.execute_command(params)
|
|
|
|
end
|
|
|
|
|
2021-09-06 13:29:42 +02:00
|
|
|
-- Typescript Language Server
|
2021-11-22 18:45:07 +01:00
|
|
|
lsp.tsserver.setup {
|
2022-01-26 20:42:58 +01:00
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = lsp_status.capabilities,
|
|
|
|
commands = {
|
|
|
|
OrganizeImports = {
|
|
|
|
organize_imports,
|
|
|
|
description = "Organize Imports"
|
|
|
|
}
|
|
|
|
}
|
2021-09-06 13:29:42 +02:00
|
|
|
}
|
|
|
|
|
2021-11-22 18:45:07 +01:00
|
|
|
-- JSON ls setup
|
|
|
|
lsp.jsonls.setup {
|
2022-01-26 20:42:58 +01:00
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = lsp_status.capabilities
|
2021-11-22 18:45:07 +01:00
|
|
|
}
|
|
|
|
|
2021-08-12 13:12:30 +02:00
|
|
|
-- Setup diagnostics formaters and linters for non LSP provided files
|
2021-11-22 18:45:07 +01:00
|
|
|
lsp.diagnosticls.setup {
|
2022-01-26 20:42:58 +01:00
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = lsp_status.capabilities,
|
|
|
|
cmd = {"diagnostic-languageserver", "--stdio"},
|
|
|
|
filetypes = {
|
|
|
|
"sh",
|
|
|
|
"markdown",
|
|
|
|
"yaml",
|
|
|
|
"toml"
|
|
|
|
},
|
|
|
|
init_options = {
|
|
|
|
linters = {
|
|
|
|
shellcheck = {
|
|
|
|
command = "shellcheck",
|
|
|
|
debounce = 100,
|
|
|
|
args = {"--format", "json", "-"},
|
|
|
|
sourceName = "shellcheck",
|
|
|
|
parseJson = {
|
|
|
|
line = "line",
|
|
|
|
column = "column",
|
|
|
|
endLine = "endLine",
|
|
|
|
endColumn = "endColumn",
|
|
|
|
message = "${message} [${code}]",
|
|
|
|
security = "level"
|
|
|
|
},
|
|
|
|
securities = {
|
|
|
|
error = "error",
|
|
|
|
warning = "warning",
|
|
|
|
info = "info",
|
|
|
|
style = "hint"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
markdownlint = {
|
|
|
|
command = "markdownlint",
|
|
|
|
isStderr = true,
|
|
|
|
debounce = 100,
|
|
|
|
args = {"--stdin"},
|
|
|
|
offsetLine = 0,
|
|
|
|
offsetColumn = 0,
|
|
|
|
sourceName = "markdownlint",
|
|
|
|
formatLines = 1,
|
|
|
|
formatPattern = {
|
|
|
|
"^.*?:\\s?(\\d+)(:(\\d+)?)?\\s(MD\\d{3}\\/[A-Za-z0-9-/]+)\\s(.*)$",
|
|
|
|
{
|
|
|
|
line = 1,
|
|
|
|
column = 3,
|
|
|
|
message = {4}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
filetypes = {
|
|
|
|
sh = "shellcheck",
|
|
|
|
markdown = "markdownlint"
|
|
|
|
},
|
|
|
|
formatters = {
|
|
|
|
shfmt = {
|
|
|
|
command = "shfmt",
|
|
|
|
args = {"-i", "2", "-bn", "-ci", "-sr"}
|
|
|
|
},
|
|
|
|
prettier = {
|
|
|
|
command = "prettier",
|
|
|
|
args = {"--stdin-filepath", "%filepath"}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
formatFiletypes = {
|
|
|
|
sh = "shfmt",
|
|
|
|
json = "prettier",
|
|
|
|
yaml = "prettier",
|
|
|
|
toml = "prettier",
|
|
|
|
markdown = "prettier",
|
|
|
|
lua = "prettier"
|
|
|
|
}
|
|
|
|
}
|
2021-08-12 13:12:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
-- Enable diagnostics
|
|
|
|
vim.lsp.handlers["textDocument/publishDiagnostics"] =
|
2022-01-26 20:42:58 +01:00
|
|
|
vim.lsp.with(
|
|
|
|
vim.lsp.diagnostic.on_publish_diagnostics,
|
|
|
|
{
|
|
|
|
underline = true,
|
|
|
|
virtual_text = false,
|
|
|
|
signs = true,
|
|
|
|
update_in_insert = true
|
|
|
|
}
|
2021-08-12 13:12:30 +02:00
|
|
|
)
|