[LSP] Improve TS, TSX, JS, JSX, Vue handling
This commit is contained in:
parent
3e6fae6379
commit
d7b445365d
@ -6,10 +6,10 @@ return {
|
|||||||
"hrsh7th/cmp-nvim-lsp",
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
{ "antosha417/nvim-lsp-file-operations", config = true },
|
{ "antosha417/nvim-lsp-file-operations", config = true },
|
||||||
-- "mfussenegger/nvim-jdtls",
|
-- "mfussenegger/nvim-jdtls",
|
||||||
"nvim-java/nvim-java"
|
"nvim-java/nvim-java",
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
require('java').setup()
|
require("java").setup()
|
||||||
-- import lspconfig plugin
|
-- import lspconfig plugin
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require("lspconfig")
|
||||||
|
|
||||||
@ -142,6 +142,27 @@ return {
|
|||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
lspconfig.ts_ls.setup({
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
init_options = {
|
||||||
|
plugins = {
|
||||||
|
{
|
||||||
|
name = "@vue/typescript-plugin",
|
||||||
|
location = "/usr/local/lib/node_modules/@vue/typescript-plugin",
|
||||||
|
languages = { "javascript", "typescript", "vue" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
filetypes = {
|
||||||
|
"javascript",
|
||||||
|
"typescript",
|
||||||
|
"typescriptreact",
|
||||||
|
"javascriptreact",
|
||||||
|
"vue",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
local java_on_attach = function(client, bufnr)
|
local java_on_attach = function(client, bufnr)
|
||||||
on_attach(client, bufnr)
|
on_attach(client, bufnr)
|
||||||
|
|
||||||
@ -187,33 +208,32 @@ return {
|
|||||||
on_attach = java_on_attach,
|
on_attach = java_on_attach,
|
||||||
})
|
})
|
||||||
|
|
||||||
lspconfig.texlab.setup{
|
lspconfig.texlab.setup({
|
||||||
cmd = { "texlab" },
|
cmd = { "texlab" },
|
||||||
filetypes = { "tex", "latex", "bib" },
|
filetypes = { "tex", "latex", "bib" },
|
||||||
root_dir = function(fname)
|
root_dir = function(fname)
|
||||||
return vim.loop.cwd()
|
return vim.loop.cwd()
|
||||||
end,
|
end,
|
||||||
}
|
})
|
||||||
|
|
||||||
local lspconfutil = require 'lspconfig/util'
|
local lspconfutil = require("lspconfig/util")
|
||||||
local root_pattern = lspconfutil.root_pattern("veridian.yml", ".git", ".xpr")
|
local root_pattern = lspconfutil.root_pattern("veridian.yml", ".git", ".xpr")
|
||||||
local verilog_root_dir = function ()
|
local verilog_root_dir = function()
|
||||||
local filename = lspconfutil.path.join(vim.loop.cwd(), fname)
|
local filename = lspconfutil.path.join(vim.loop.cwd(), fname)
|
||||||
return root_pattern(filename) or lspconfutil.path.dirname(filename)
|
return root_pattern(filename) or lspconfutil.path.dirname(filename)
|
||||||
end
|
end
|
||||||
lspconfig.veridian.setup {
|
lspconfig.veridian.setup({
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
root_dir = verilog_root_dir
|
root_dir = verilog_root_dir,
|
||||||
}
|
})
|
||||||
|
|
||||||
lspconfig.verible.setup( {
|
lspconfig.verible.setup({
|
||||||
-- cmd = { 'verible-verilog-ls', '--rules_config=/home/janis/.config/nvim/util/verible-conf.json' },
|
-- cmd = { 'verible-verilog-ls', '--rules_config=/home/janis/.config/nvim/util/verible-conf.json' },
|
||||||
cmd = { 'verible-verilog-ls', '--rules=-no-trailing-spaces', '' },
|
cmd = { "verible-verilog-ls", "--rules=-no-trailing-spaces", "" },
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
root_dir = verilog_root_dir
|
root_dir = verilog_root_dir,
|
||||||
} )
|
})
|
||||||
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ return {
|
|||||||
null_ls.builtins.formatting.stylua,
|
null_ls.builtins.formatting.stylua,
|
||||||
null_ls.builtins.formatting.prettier,
|
null_ls.builtins.formatting.prettier,
|
||||||
null_ls.builtins.formatting.shfmt,
|
null_ls.builtins.formatting.shfmt,
|
||||||
|
null_ls.builtins.diagnostics.eslint,
|
||||||
null_ls.builtins.formatting.black,
|
null_ls.builtins.formatting.black,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -1,79 +0,0 @@
|
|||||||
return {
|
|
||||||
"pmizio/typescript-tools.nvim",
|
|
||||||
dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
|
|
||||||
opts = {},
|
|
||||||
ft = { "javascript", "javascriptreact", "typescript", "typescriptreact", "vue" },
|
|
||||||
config = function()
|
|
||||||
require("typescript-tools").setup({
|
|
||||||
on_attach = function(client, bufnr)
|
|
||||||
local opts = { silent = true }
|
|
||||||
local keymap = vim.keymap
|
|
||||||
opts.buffer = bufnr
|
|
||||||
|
|
||||||
-- set keybinds
|
|
||||||
opts.desc = "Show LSP references"
|
|
||||||
keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts)
|
|
||||||
|
|
||||||
opts.desc = "Go to declaration"
|
|
||||||
keymap.set("n", "gD", ":lua vim.lsp.buf.declaration", opts)
|
|
||||||
|
|
||||||
opts.desc = "Show LSP definitions"
|
|
||||||
keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts)
|
|
||||||
|
|
||||||
opts.desc = "Show LSP implementations"
|
|
||||||
keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts)
|
|
||||||
|
|
||||||
opts.desc = "Show LSP type definitions"
|
|
||||||
keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts)
|
|
||||||
|
|
||||||
opts.desc = "See available code actions"
|
|
||||||
keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
|
|
||||||
|
|
||||||
opts.desc = "Format current file"
|
|
||||||
keymap.set("n", "<leader>gf", vim.lsp.buf.format, opts)
|
|
||||||
|
|
||||||
opts.desc = "Smart rename"
|
|
||||||
keymap.set("n", "<leader>n", vim.lsp.buf.rename, opts)
|
|
||||||
|
|
||||||
opts.desc = "Show buffer diagnostics"
|
|
||||||
keymap.set("n", "ga", "<cmd>Telescope diagnostics bufnr=0<CR>", opts)
|
|
||||||
|
|
||||||
opts.desc = "Show line diagnostics"
|
|
||||||
keymap.set("n", "gA", ":lua vim.diagnostic.open_float()<CR>", opts)
|
|
||||||
|
|
||||||
opts.desc = "Go to previous diagnostic"
|
|
||||||
keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
|
|
||||||
|
|
||||||
opts.desc = "Go to next diagnostic"
|
|
||||||
keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
|
|
||||||
|
|
||||||
opts.desc = "Show documentation for what is under cursor"
|
|
||||||
keymap.set("n", "<leader>k", vim.lsp.buf.hover, opts)
|
|
||||||
|
|
||||||
opts.desc = "Restart LSP"
|
|
||||||
keymap.set("n", "<leader>rs", ":LspRestart<CR>", opts)
|
|
||||||
|
|
||||||
vim.opt.signcolumn = "yes" -- reserve space for diagnostics
|
|
||||||
|
|
||||||
client.server_capabilities.documentFormattingProvider = false
|
|
||||||
client.server_capabilities.documentRangeFormattingProvider = false
|
|
||||||
end,
|
|
||||||
filetypes = {
|
|
||||||
"javascript",
|
|
||||||
"javascriptreact",
|
|
||||||
"typescript",
|
|
||||||
"typescriptreact",
|
|
||||||
"vue",
|
|
||||||
},
|
|
||||||
settings = {
|
|
||||||
tsserver_plugins = {
|
|
||||||
"@vue/typescript-plugin",
|
|
||||||
},
|
|
||||||
jsx_close_tag = {
|
|
||||||
enable = true,
|
|
||||||
filetypes = { "javascriptreact", "typescriptreact" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user