mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-21 11:05:08 +02:00
Better JS/TS Development Experience (#667)
Co-authored-by: Maxime <m.romero@progtechinformatique.ca>
This commit is contained in:
parent
f93c007962
commit
d2324d14e1
3 changed files with 61 additions and 30 deletions
|
@ -106,8 +106,48 @@ if O.document_highlight then
|
||||||
end
|
end
|
||||||
|
|
||||||
function lsp_config.tsserver_on_attach(client, bufnr)
|
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
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,46 +17,18 @@ M.setup = function()
|
||||||
}
|
}
|
||||||
end
|
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 {
|
require"lspconfig".efm.setup {
|
||||||
-- init_options = {initializationOptions},
|
-- init_options = {initializationOptions},
|
||||||
cmd = {DATA_PATH .. "/lspinstall/efm/efm-langserver"},
|
cmd = {DATA_PATH .. "/lspinstall/efm/efm-langserver"},
|
||||||
init_options = {documentFormatting = true, codeAction = false},
|
init_options = {documentFormatting = true, codeAction = false},
|
||||||
filetypes = {
|
filetypes = {"html", "css", "yaml", "vue"},
|
||||||
"javascriptreact", "javascript", "typescript", "typescriptreact",
|
|
||||||
"html", "css", "yaml", "vue"
|
|
||||||
},
|
|
||||||
settings = {
|
settings = {
|
||||||
rootMarkers = {".git/", "package.json"},
|
rootMarkers = {".git/", "package.json"},
|
||||||
languages = {
|
languages = {
|
||||||
javascript = tsserver_args,
|
|
||||||
javascriptreact = tsserver_args,
|
|
||||||
typescript = tsserver_args,
|
|
||||||
typescriptreact = tsserver_args,
|
|
||||||
html = {prettier},
|
html = {prettier},
|
||||||
css = {prettier},
|
css = {prettier},
|
||||||
json = {prettier},
|
json = {prettier},
|
||||||
yaml = {prettier}
|
yaml = {prettier}
|
||||||
-- javascriptreact = {prettier, eslint},
|
|
||||||
-- javascript = {prettier, eslint},
|
|
||||||
-- markdown = {markdownPandocFormat, markdownlint},
|
-- markdown = {markdownPandocFormat, markdownlint},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -429,6 +429,25 @@ return require("packer").startup(function(use)
|
||||||
-- Elixir
|
-- Elixir
|
||||||
use {"elixir-editors/vim-elixir", ft = {"elixir", "eelixir", "euphoria3"}}
|
use {"elixir-editors/vim-elixir", ft = {"elixir", "eelixir", "euphoria3"}}
|
||||||
|
|
||||||
|
-- Javascript / Typescript
|
||||||
|
use {
|
||||||
|
"jose-elias-alvarez/nvim-lsp-ts-utils",
|
||||||
|
ft = {
|
||||||
|
"javascript", "javascriptreact", "javascript.jsx", "typescript",
|
||||||
|
"typescriptreact", "typescript.tsx"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
use {
|
||||||
|
"jose-elias-alvarez/null-ls.nvim",
|
||||||
|
ft = {
|
||||||
|
"javascript", "javascriptreact", "javascript.jsx", "typescript",
|
||||||
|
"typescriptreact", "typescript.tsx"
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require('null-ls').setup()
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
-- Tabnine
|
-- Tabnine
|
||||||
use {
|
use {
|
||||||
"tzachar/compe-tabnine",
|
"tzachar/compe-tabnine",
|
||||||
|
|
Loading…
Reference in a new issue