summaryrefslogtreecommitdiff
path: root/lua/lsp
diff options
context:
space:
mode:
Diffstat (limited to 'lua/lsp')
-rw-r--r--lua/lsp/emmet-ls.lua6
-rw-r--r--lua/lsp/init.lua62
-rw-r--r--lua/lsp/ts-fmt-lint.lua33
3 files changed, 63 insertions, 38 deletions
diff --git a/lua/lsp/emmet-ls.lua b/lua/lsp/emmet-ls.lua
index 46d6c90d..fcb7f62d 100644
--- a/lua/lsp/emmet-ls.lua
+++ b/lua/lsp/emmet-ls.lua
@@ -1,3 +1,7 @@
+-- if not package.loaded['lspconfig'] then
+-- return
+-- end
+
local nvim_lsp = require'lspconfig'
local configs = require'lspconfig/configs'
local capabilities = vim.lsp.protocol.make_client_capabilities()
@@ -6,7 +10,7 @@ capabilities.textDocument.completion.completionItem.snippetSupport = true
configs.emmet_ls = {
default_config = {
cmd = {'emmet-ls', '--stdio'};
- filetypes = {'html', 'css', 'javascript', 'javascriptreact', 'typescript', 'typescriptreact'};
+ filetypes = {'html', 'css', 'javascript', 'typescript'};
root_dir = function()
return vim.loop.cwd()
end;
diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua
index 8bc8984f..0292064a 100644
--- a/lua/lsp/init.lua
+++ b/lua/lsp/init.lua
@@ -20,14 +20,12 @@ vim.cmd("nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>")
vim.cmd("nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>")
vim.cmd("nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>")
vim.cmd("nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>")
-vim.cmd("nnoremap <silent> K :Lspsaga hover_doc<CR>")
+vim.cmd("nnoremap <silent> K :lua vim.lsp.buf.hover()<CR>")
-- vim.cmd('nnoremap <silent> <C-k> <cmd>lua vim.lsp.buf.signature_help()<CR>')
-vim.cmd("nnoremap <silent> <C-p> :Lspsaga diagnostic_jump_prev<CR>")
-vim.cmd("nnoremap <silent> <C-n> :Lspsaga diagnostic_jump_next<CR>")
+vim.cmd("nnoremap <silent> <C-p> :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = O.lsp.popup_border}})<CR>")
+vim.cmd("nnoremap <silent> <C-n> :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = O.lsp.popup_border}})<CR>")
-- scroll down hover doc or scroll in definition preview
-vim.cmd("nnoremap <silent> <C-f> <cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>")
-- scroll up hover doc
-vim.cmd("nnoremap <silent> <C-b> <cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>")
vim.cmd('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()')
-- Set Default Prefix.
@@ -43,6 +41,18 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
}
)
+vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
+ vim.lsp.handlers.hover, {
+ border = O.lsp.popup_border
+ }
+)
+
+vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
+ vim.lsp.handlers.signature_help, {
+ border = O.lsp.popup_border
+ }
+)
+
-- symbols for autocomplete
vim.lsp.protocol.CompletionItemKind = {
" ï’ž (Text) ",
@@ -106,8 +116,48 @@ if O.document_highlight then
end
function lsp_config.tsserver_on_attach(client, bufnr)
- lsp_config.common_on_attach(client, bufnr)
+ -- lsp_config.common_on_attach(client, bufnr)
client.resolved_capabilities.document_formatting = false
+
+ local ts_utils = require("nvim-lsp-ts-utils")
+
+ -- defaults
+ ts_utils.setup {
+ debug = false,
+ disable_commands = false,
+ enable_import_on_completion = false,
+ import_all_timeout = 5000, -- ms
+
+ -- eslint
+ eslint_enable_code_actions = true,
+ eslint_enable_disable_comments = true,
+ eslint_bin = O.lang.tsserver.linter,
+ eslint_config_fallback = nil,
+ eslint_enable_diagnostics = true,
+
+ -- formatting
+ enable_formatting = O.lang.tsserver.autoformat,
+ formatter = O.lang.tsserver.formatter,
+ formatter_config_fallback = nil,
+
+ -- parentheses completion
+ complete_parens = false,
+ signature_help_in_parens = false,
+
+ -- update imports on file move
+ update_imports_on_move = false,
+ require_confirmation_on_move = false,
+ watch_dir = nil,
+ }
+
+ -- required to fix code action ranges
+ ts_utils.setup_client(client)
+
+ -- TODO: keymap these?
+ -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gs", ":TSLspOrganize<CR>", {silent = true})
+ -- vim.api.nvim_buf_set_keymap(bufnr, "n", "qq", ":TSLspFixCurrent<CR>", {silent = true})
+ -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", ":TSLspRenameFile<CR>", {silent = true})
+ -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", ":TSLspImportAll<CR>", {silent = true})
end
diff --git a/lua/lsp/ts-fmt-lint.lua b/lua/lsp/ts-fmt-lint.lua
index 3ca97d71..36d4ca8a 100644
--- a/lua/lsp/ts-fmt-lint.lua
+++ b/lua/lsp/ts-fmt-lint.lua
@@ -10,54 +10,25 @@ M.setup = function()
formatStdin = true
}
- if vim.fn.glob("node_modules/.bin/prettier") then
+ if vim.fn.glob("node_modules/.bin/prettier") ~= "" then
prettier = {
formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}",
formatStdin = true
}
end
- -- TODO global eslint?
-
- local eslint = {
- lintCommand = "./node_modules/.bin/eslint -f unix --stdin --stdin-filename ${INPUT}",
- lintIgnoreExitCode = true,
- lintStdin = true,
- lintFormats = {"%f:%l:%c: %m"},
- -- formatCommand = "./node_modules/.bin/eslint -f unix --fix --stdin-filename ${INPUT}", -- TODO check if eslint is the formatter then add this
- formatStdin = true
- }
-
- if O.lang.tsserver.formatter == 'prettier' then
- table.insert(tsserver_args, prettier)
- end
-
- if O.lang.tsserver.linter == 'eslint' then
- table.insert(tsserver_args, eslint)
- end
-
require"lspconfig".efm.setup {
-- init_options = {initializationOptions},
cmd = {DATA_PATH .. "/lspinstall/efm/efm-langserver"},
init_options = {documentFormatting = true, codeAction = false},
- filetypes = {
- "javascriptreact", "javascript", "typescript", "typescriptreact",
- "html", "css", "yaml", "vue"
- },
+ filetypes = {"html", "css", "yaml", "vue", "javascript", "javascriptreact", "typescript", "typescriptreact"},
settings = {
rootMarkers = {".git/", "package.json"},
languages = {
- javascript = tsserver_args,
- javascriptreact = tsserver_args,
- typescript = tsserver_args,
- typescriptreact = tsserver_args,
html = {prettier},
css = {prettier},
json = {prettier},
yaml = {prettier}
- -- javascriptreact = {prettier, eslint},
- -- javascript = {prettier, eslint},
- -- markdown = {markdownPandocFormat, markdownlint},
}
}
}