diff options
Diffstat (limited to 'lua/lsp')
-rw-r--r-- | lua/lsp/angular-ls.lua | 6 | ||||
-rw-r--r-- | lua/lsp/emmet-ls.lua | 23 | ||||
-rw-r--r-- | lua/lsp/init.lua | 76 | ||||
-rw-r--r-- | lua/lsp/julia/Manifest.toml | 182 | ||||
-rw-r--r-- | lua/lsp/julia/Project.toml | 3 | ||||
-rw-r--r-- | lua/lsp/julia/run.jl | 37 | ||||
-rw-r--r-- | lua/lsp/null-ls.lua | 70 | ||||
-rw-r--r-- | lua/lsp/svelte-ls.lua | 5 | ||||
-rw-r--r-- | lua/lsp/tailwindcss-ls.lua | 13 | ||||
-rw-r--r-- | lua/lsp/ts-fmt-lint.lua | 72 | ||||
-rw-r--r-- | lua/lsp/tsserver-ls.lua | 83 |
11 files changed, 119 insertions, 451 deletions
diff --git a/lua/lsp/angular-ls.lua b/lua/lsp/angular-ls.lua deleted file mode 100644 index 818faf38..00000000 --- a/lua/lsp/angular-ls.lua +++ /dev/null @@ -1,6 +0,0 @@ --- TODO: find correct root filetype --- :LspInstall angular -require("lspconfig").angularls.setup { - cmd = { DATA_PATH .. "/lspinstall/angular/node_modules/@angular/language-server/bin/ngserver", "--stdio" }, - on_attach = require("lsp").common_on_attach, -} diff --git a/lua/lsp/emmet-ls.lua b/lua/lsp/emmet-ls.lua deleted file mode 100644 index e38747ac..00000000 --- a/lua/lsp/emmet-ls.lua +++ /dev/null @@ -1,23 +0,0 @@ --- 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() -capabilities.textDocument.completion.completionItem.snippetSupport = true - -configs.emmet_ls = { - default_config = { - cmd = { "emmet-ls", "--stdio" }, - filetypes = { "html", "css", "javascript", "typescript", "vue" }, - root_dir = function() - return vim.loop.cwd() - end, - settings = {}, - }, -} - -nvim_lsp.emmet_ls.setup { - -- on_attach = on_attach; -} diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua index 7884f763..b0511f0e 100644 --- a/lua/lsp/init.lua +++ b/lua/lsp/init.lua @@ -1,4 +1,5 @@ --- TODO: figure out why this don't work +local lsp_config = {} + vim.fn.sign_define( "LspDiagnosticsSignError", { texthl = "LspDiagnosticsSignError", text = "ï™™", numhl = "LspDiagnosticsSignError" } @@ -37,7 +38,7 @@ vim.fn.sign_define( -- { noremap = true, silent = true } -- ) -if O.lsp.default_keybinds then +if lvim.lsp.default_keybinds then 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>" @@ -51,8 +52,8 @@ if O.lsp.default_keybinds then vim.cmd "nnoremap <silent> gp <cmd>lua require'lsp'.PeekDefinition()<CR>" vim.cmd "nnoremap <silent> K :lua vim.lsp.buf.hover()<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>" + vim.cmd "nnoremap <silent> <C-p> :lua vim.lsp.diagnostic.goto_prev({popup_opts = {border = lvim.lsp.popup_border}})<CR>" + vim.cmd "nnoremap <silent> <C-n> :lua vim.lsp.diagnostic.goto_next({popup_opts = {border = lvim.lsp.popup_border}})<CR>" vim.cmd "nnoremap <silent> <tab> <cmd>lua vim.lsp.buf.signature_help()<CR>" -- scroll down hover doc or scroll in definition preview -- scroll up hover doc @@ -61,19 +62,21 @@ end -- Set Default Prefix. -- Note: You can set a prefix per lsp server in the lv-globals.lua file -vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = O.lsp.diagnostics.virtual_text, - signs = O.lsp.diagnostics.signs, - underline = O.lsp.document_highlight, -}) +function lsp_config.setup_handlers() + vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = lvim.lsp.diagnostics.virtual_text, + signs = lvim.lsp.diagnostics.signs, + underline = lvim.lsp.document_highlight, + }) -vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { - border = O.lsp.popup_border, -}) + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = lvim.lsp.popup_border, + }) -vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { - border = O.lsp.popup_border, -}) + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = lvim.lsp.popup_border, + }) +end -- symbols for autocomplete vim.lsp.protocol.CompletionItemKind = { @@ -112,7 +115,7 @@ autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]] -- autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR> local function lsp_highlight_document(client) - if O.lsp.document_highlight == false then + if lvim.lsp.document_highlight == false then return -- we don't need further end -- Set autocommands conditional on server_capabilities @@ -132,7 +135,6 @@ local function lsp_highlight_document(client) ) end end -local lsp_config = {} -- Taken from https://www.reddit.com/r/neovim/comments/gyb077/nvimlsp_peek_defination_javascript_ttserver/ function lsp_config.preview_location(location, context, before_context) @@ -156,7 +158,7 @@ function lsp_config.preview_location(location, context, before_context) false ) local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype") - return vim.lsp.util.open_floating_preview(contents, filetype, { border = O.lsp.popup_border }) + return vim.lsp.util.open_floating_preview(contents, filetype, { border = lvim.lsp.popup_border }) end function lsp_config.preview_location_callback(_, method, result) @@ -200,12 +202,25 @@ function lsp_config.PeekImplementation() end function lsp_config.common_on_attach(client, bufnr) - if O.lsp.on_attach_callback then - O.lsp.on_attach_callback(client, bufnr) + if lvim.lsp.on_attach_callback then + lvim.lsp.on_attach_callback(client, bufnr) end lsp_highlight_document(client) end +function lsp_config.common_capabilities() + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities.textDocument.completion.completionItem.snippetSupport = true + capabilities.textDocument.completion.completionItem.resolveSupport = { + properties = { + "documentation", + "detail", + "additionalTextEdits", + }, + } + return capabilities +end + function lsp_config.tsserver_on_attach(client, _) -- lsp_config.common_on_attach(client, bufnr) client.resolved_capabilities.document_formatting = false @@ -222,13 +237,13 @@ function lsp_config.tsserver_on_attach(client, _) -- eslint eslint_enable_code_actions = true, eslint_enable_disable_comments = true, - -- eslint_bin = O.lang.tsserver.linter, + -- eslint_bin = lvim.lang.tsserver.linter, eslint_config_fallback = nil, eslint_enable_diagnostics = true, -- formatting - enable_formatting = O.lang.tsserver.autoformat, - formatter = O.lang.tsserver.formatter.exe, + enable_formatting = lvim.lang.tsserver.autoformat, + formatter = lvim.lang.tsserver.formatter.exe, formatter_config_fallback = nil, -- parentheses completion @@ -257,8 +272,15 @@ require("lv-utils").define_augroups { }, } --- Use a loop to conveniently both setup defined servers --- and map buffer local keybindings when the language server attaches --- local servers = {"pyright", "tsserver"} --- for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {on_attach = on_attach} end +function lsp_config.setup(lang) + lang_server = lvim.lang[lang].lsp + require("lsp.null-ls").setup "python" + local provider = lang_server.provider + if require("lv-utils").check_lsp_client_active(provider) then + return + end + require("lspconfig")[provider].setup(lang_server.setup) + require("lsp.null-ls").setup(lang) +end + return lsp_config diff --git a/lua/lsp/julia/Manifest.toml b/lua/lsp/julia/Manifest.toml deleted file mode 100644 index c6c12950..00000000 --- a/lua/lsp/julia/Manifest.toml +++ /dev/null @@ -1,182 +0,0 @@ -# This file is machine-generated - editing it directly is not advised - -[[ArgTools]] -uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" - -[[Artifacts]] -uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" - -[[Base64]] -uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" - -[[CSTParser]] -deps = ["Tokenize"] -git-tree-sha1 = "9723e1c07c1727082e169ca50789644a552fb023" -uuid = "00ebfdb7-1f24-5e51-bd34-a7502290713f" -version = "3.2.3" - -[[Dates]] -deps = ["Printf"] -uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" - -[[DocumentFormat]] -deps = ["CSTParser", "FilePathsBase", "Tokenize"] -git-tree-sha1 = "cf048d65cbcdec70f10745e5801eeb0c6478a7f7" -uuid = "ffa9a821-9c82-50df-894e-fbcef3ed31cd" -version = "3.2.4" - -[[Downloads]] -deps = ["ArgTools", "LibCURL", "NetworkOptions"] -uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" - -[[FilePathsBase]] -deps = ["Dates", "Mmap", "Printf", "Test", "UUIDs"] -git-tree-sha1 = "0f5e8d0cb91a6386ba47bd1527b240bd5725fbae" -uuid = "48062228-2e41-5def-b9a4-89aafe57970f" -version = "0.9.10" - -[[InteractiveUtils]] -deps = ["Markdown"] -uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" - -[[JSON]] -deps = ["Dates", "Mmap", "Parsers", "Unicode"] -git-tree-sha1 = "81690084b6198a2e1da36fcfda16eeca9f9f24e4" -uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" -version = "0.21.1" - -[[JSONRPC]] -deps = ["JSON", "UUIDs"] -git-tree-sha1 = "1e9a820a29b37864a6738b8fd00eedf3fb8d772e" -uuid = "b9b8584e-8fd3-41f9-ad0c-7255d428e418" -version = "1.3.3" - -[[LanguageServer]] -deps = ["CSTParser", "DocumentFormat", "JSON", "JSONRPC", "Markdown", "Pkg", "REPL", "StaticLint", "SymbolServer", "Tokenize", "URIParser", "UUIDs"] -git-tree-sha1 = "ac9f7da10fbba9cad8455a3436d121eaf8f308f6" -uuid = "2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7" -version = "4.0.0" - -[[LibCURL]] -deps = ["LibCURL_jll", "MozillaCACerts_jll"] -uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" - -[[LibCURL_jll]] -deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] -uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" - -[[LibGit2]] -deps = ["Base64", "NetworkOptions", "Printf", "SHA"] -uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" - -[[LibSSH2_jll]] -deps = ["Artifacts", "Libdl", "MbedTLS_jll"] -uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" - -[[Libdl]] -uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" - -[[Logging]] -uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" - -[[Markdown]] -deps = ["Base64"] -uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" - -[[MbedTLS_jll]] -deps = ["Artifacts", "Libdl"] -uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" - -[[Mmap]] -uuid = "a63ad114-7e13-5084-954f-fe012c677804" - -[[MozillaCACerts_jll]] -uuid = "14a3606d-f60d-562e-9121-12d972cd8159" - -[[NetworkOptions]] -uuid = "ca575930-c2e3-43a9-ace4-1e988b2c1908" - -[[Parsers]] -deps = ["Dates"] -git-tree-sha1 = "c8abc88faa3f7a3950832ac5d6e690881590d6dc" -uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "1.1.0" - -[[Pkg]] -deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] -uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" - -[[Printf]] -deps = ["Unicode"] -uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" - -[[REPL]] -deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] -uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" - -[[Random]] -deps = ["Serialization"] -uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" - -[[SHA]] -uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" - -[[Serialization]] -uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" - -[[Sockets]] -uuid = "6462fe0b-24de-5631-8697-dd941f90decc" - -[[StaticLint]] -deps = ["CSTParser", "Serialization", "SymbolServer"] -git-tree-sha1 = "337ca6f234947b31e921a424f7d0ec8dda22ed49" -uuid = "b3cc710f-9c33-5bdb-a03d-a94903873e97" -version = "8.0.0" - -[[SymbolServer]] -deps = ["InteractiveUtils", "LibGit2", "Markdown", "Pkg", "REPL", "SHA", "Serialization", "Sockets", "UUIDs"] -git-tree-sha1 = "9053544866f779dfb87027c52a332e2830e868ab" -uuid = "cf896787-08d5-524d-9de7-132aaa0cb996" -version = "7.0.0" - -[[TOML]] -deps = ["Dates"] -uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" - -[[Tar]] -deps = ["ArgTools", "SHA"] -uuid = "a4e569a6-e804-4fa4-b0f3-eef7a1d5b13e" - -[[Test]] -deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] -uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[[Tokenize]] -git-tree-sha1 = "eee92eda3cc8e104b7e56ff4c1fcf0d78ca37c89" -uuid = "0796e94c-ce3b-5d07-9a54-7f471281c624" -version = "0.5.18" - -[[URIParser]] -deps = ["Unicode"] -git-tree-sha1 = "53a9f49546b8d2dd2e688d216421d050c9a31d0d" -uuid = "30578b45-9adc-5946-b283-645ec420af67" -version = "0.4.1" - -[[UUIDs]] -deps = ["Random", "SHA"] -uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" - -[[Unicode]] -uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" - -[[Zlib_jll]] -deps = ["Libdl"] -uuid = "83775a58-1f1d-513f-b197-d71354ab007a" - -[[nghttp2_jll]] -deps = ["Artifacts", "Libdl"] -uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" - -[[p7zip_jll]] -deps = ["Artifacts", "Libdl"] -uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" diff --git a/lua/lsp/julia/Project.toml b/lua/lsp/julia/Project.toml deleted file mode 100644 index 50cd7702..00000000 --- a/lua/lsp/julia/Project.toml +++ /dev/null @@ -1,3 +0,0 @@ -[deps] -LanguageServer = "2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7" -SymbolServer = "cf896787-08d5-524d-9de7-132aaa0cb996" diff --git a/lua/lsp/julia/run.jl b/lua/lsp/julia/run.jl deleted file mode 100644 index 4662e1b2..00000000 --- a/lua/lsp/julia/run.jl +++ /dev/null @@ -1,37 +0,0 @@ -# Load LanguageServer from the project next to this file -## Save old load path -old_load_path = copy(LOAD_PATH) -push!(empty!(LOAD_PATH), @__DIR__) -## Load packages -using LanguageServer, SymbolServer -## Restore old load path -append!(empty!(LOAD_PATH), old_load_path) - -# Figure out the active project -## This configuration is a good default -project_path = let - dirname(something( - ## 1. Finds an explicitly set project (JULIA_PROJECT) - Base.load_path_expand(( - p = get(ENV, "JULIA_PROJECT", nothing); - p === nothing ? nothing : isempty(p) ? nothing : p - )), - ## 2. Look for a Project.toml file in the current working directory, - ## or parent directories, with $HOME as an upper boundary - Base.current_project(), - ## 3. First entry in the load path - get(Base.load_path(), 1, nothing), - ## 4. Fallback to default global environment, - ## this is more or less unreachable - Base.load_path_expand("@v#.#"), - )) -end - -# Depot path for the server to index (empty uses default). -depot_path = get(ENV, "JULIA_DEPOT_PATH", "") - -# Start the server -@info "Running julia language server" VERSION project_path depot_path -server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path) -server.runlinter = true -run(server) diff --git a/lua/lsp/null-ls.lua b/lua/lsp/null-ls.lua new file mode 100644 index 00000000..43d4400a --- /dev/null +++ b/lua/lsp/null-ls.lua @@ -0,0 +1,70 @@ +local M = {} + +local null_ls = require "null-ls" +local sources = {} + +local local_executables = { "prettier", "prettierd", "prettier_d_slim", "eslint_d", "eslint" } + +local function is_table(t) + return type(t) == "table" +end + +local function is_string(t) + return type(t) == "string" +end + +local function has_value(tab, val) + for index, value in ipairs(tab) do + if value == val then + return true + end + end + + return false +end + +local find_local_exe = function(exe) + vim.cmd "let root_dir = FindRootDirectory()" + local root_dir = vim.api.nvim_get_var "root_dir" + local local_exe = root_dir .. "/node_modules/.bin/" .. exe + return local_exe +end + +local function setup_ls(exe, type) + if has_value(local_executables, exe) then + local smart_executable = null_ls.builtins[type][exe] + local local_executable = find_local_exe(exe) + if vim.fn.executable(local_executable) then + smart_executable._opts.command = local_executable + end + table.insert(sources, smart_executable) + else + table.insert(sources, null_ls.builtins[type][exe]) + end + null_ls.register { sources = sources } +end + +local function setup(filetype, type) + if type == "diagnostics" then + executables = lvim.lang[filetype].linters + end + if type == "formatting" then + executables = lvim.lang[filetype].formatter.exe + end + + if is_table(executables) then + for _, exe in pairs(executables) do + setup_ls(exe, type) + end + end + if is_string(executables) then + setup_ls(executables, type) + end +end + +function M.setup(filetype) + setup(filetype, "formatting") + setup(filetype, "diagnostics") +end + +return M diff --git a/lua/lsp/svelte-ls.lua b/lua/lsp/svelte-ls.lua deleted file mode 100644 index e5ddb3b3..00000000 --- a/lua/lsp/svelte-ls.lua +++ /dev/null @@ -1,5 +0,0 @@ --- TODO: what is a svelte filetype -require("lspconfig").svelte.setup { - cmd = { DATA_PATH .. "/lspinstall/svelte/node_modules/.bin/svelteserver", "--stdio" }, - on_attach = require("lsp").common_on_attach, -} diff --git a/lua/lsp/tailwindcss-ls.lua b/lua/lsp/tailwindcss-ls.lua deleted file mode 100644 index 38c1e7cc..00000000 --- a/lua/lsp/tailwindcss-ls.lua +++ /dev/null @@ -1,13 +0,0 @@ --- TODO: what is a tailwindcss filetype -local lspconfig = require "lspconfig" - -lspconfig.tailwindcss.setup { - cmd = { - "node", - DATA_PATH .. "/lspinstall/tailwindcss/tailwindcss-intellisense/extension/dist/server/tailwindServer.js", - "--stdio", - }, - filetypes = O.lang.tailwindcss.filetypes, - root_dir = require("lspconfig/util").root_pattern("tailwind.config.js", "postcss.config.ts", ".postcssrc"), - on_attach = require("lsp").common_on_attach, -} diff --git a/lua/lsp/ts-fmt-lint.lua b/lua/lsp/ts-fmt-lint.lua deleted file mode 100644 index 7cebfd86..00000000 --- a/lua/lsp/ts-fmt-lint.lua +++ /dev/null @@ -1,72 +0,0 @@ --- Example configuations here: https://github.com/mattn/efm-langserver -local M = {} - -M.setup = function() - vim.cmd "let proj = FindRootDirectory()" - local root_dir = vim.api.nvim_get_var "proj" - - local get_linter_instance = function() - -- prioritize local instance over global - local local_instance = root_dir .. "/node_modules/.bin/" .. O.lang.tsserver.linter - if vim.fn.executable(local_instance) == 1 then - return local_instance - end - return O.lang.tsserver.linter - end - - local tsserver_args = {} - local formattingSupported = false - - if O.lang.tsserver.linter == "eslint" or O.lang.tsserver.linter == "eslint_d" then - local eslint = { - lintCommand = get_linter_instance() .. " -f visualstudio --stdin --stdin-filename ${INPUT}", - lintStdin = true, - lintFormats = { - "%f(%l,%c): %tarning %m", - "%f(%l,%c): %trror %m", - }, - lintSource = O.lang.tsserver.linter, - lintIgnoreExitCode = true, - } - table.insert(tsserver_args, eslint) - -- Only eslint_d supports --fix-to-stdout - if string.find(get_linter_instance(), "eslint_d") then - formattingSupported = true - local eslint_fix = { - formatCommand = get_linter_instance() .. " --fix-to-stdout --stdin --stdin-filename ${INPUT}", - formatStdin = true, - } - table.insert(tsserver_args, eslint_fix) - end - end - - require("lspconfig").efm.setup { - -- init_options = {initializationOptions}, - cmd = { DATA_PATH .. "/lspinstall/efm/efm-langserver" }, - init_options = { documentFormatting = formattingSupported, codeAction = false }, - root_dir = require("lspconfig").util.root_pattern(".git/", "package.json"), - filetypes = { - "vue", - "javascript", - "javascriptreact", - "typescript", - "typescriptreact", - "javascript.jsx", - "typescript.tsx", - }, - settings = { - rootMarkers = { ".git/", "package.json" }, - languages = { - vue = tsserver_args, - javascript = tsserver_args, - javascriptreact = tsserver_args, - ["javascript.jsx"] = tsserver_args, - typescript = tsserver_args, - ["typescript.tsx"] = tsserver_args, - typescriptreact = tsserver_args, - }, - }, - } -end - -return M diff --git a/lua/lsp/tsserver-ls.lua b/lua/lsp/tsserver-ls.lua deleted file mode 100644 index 18e56dae..00000000 --- a/lua/lsp/tsserver-ls.lua +++ /dev/null @@ -1,83 +0,0 @@ -vim.cmd "let proj = FindRootDirectory()" -local root_dir = vim.api.nvim_get_var "proj" - --- use the global prettier if you didn't find the local one -local prettier_instance = root_dir .. "/node_modules/.bin/prettier" -if vim.fn.executable(prettier_instance) ~= 1 then - prettier_instance = O.lang.tsserver.formatter.exe -end - -O.formatters.filetype["javascriptreact"] = { - function() - local args = { "--stdin-filepath", vim.fn.fnameescape(vim.api.nvim_buf_get_name(0)) } - local extend_args = O.lang.tsserver.formatter.args - - if extend_args then - for i = 1, #extend_args do - table.insert(args, extend_args[i]) - end - end - - return { - exe = prettier_instance, - args = args, - stdin = true, - } - end, -} -O.formatters.filetype["javascript"] = O.formatters.filetype["javascriptreact"] -O.formatters.filetype["typescript"] = O.formatters.filetype["javascriptreact"] -O.formatters.filetype["typescriptreact"] = O.formatters.filetype["javascriptreact"] - -require("formatter.config").set_defaults { - logging = false, - filetype = O.formatters.filetype, -} - -if require("lv-utils").check_lsp_client_active "tsserver" then - return -end - --- npm install -g typescript typescript-language-server --- require'snippets'.use_suggested_mappings() --- local capabilities = vim.lsp.protocol.make_client_capabilities() --- capabilities.textDocument.completion.completionItem.snippetSupport = true; --- local on_attach_common = function(client) --- print("LSP Initialized") --- require'completion'.on_attach(client) --- require'illuminate'.on_attach(client) --- end - -local on_attach = function(client, bufnr) - local lsp = require "lsp" - lsp.common_on_attach(client, bufnr) - lsp.tsserver_on_attach(client, bufnr) -end - -require("lspconfig").tsserver.setup { - cmd = { - DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", - "--stdio", - }, - filetypes = { - "javascript", - "javascriptreact", - "javascript.jsx", - "typescript", - "typescriptreact", - "typescript.tsx", - }, - on_attach = on_attach, - -- This makes sure tsserver is not used for formatting (I prefer prettier) - settings = { documentFormatting = false }, - handlers = { - -- ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - -- virtual_text = O.lang.tsserver.diagnostics.virtual_text, - -- signs = O.lang.tsserver.diagnostics.signs, - -- underline = O.lang.tsserver.diagnostics.underline, - -- update_in_insert = true, - -- }), - }, -} - -require("lsp.ts-fmt-lint").setup() |