[TypeScript] Enable all LSP functions
This commit is contained in:
parent
1ac43ff80c
commit
6332f7b770
@ -1,30 +1,79 @@
|
|||||||
return {
|
return {
|
||||||
'pmizio/typescript-tools.nvim',
|
"pmizio/typescript-tools.nvim",
|
||||||
dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' },
|
dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
|
||||||
opts = {},
|
opts = {},
|
||||||
ft = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'vue' },
|
ft = { "javascript", "javascriptreact", "typescript", "typescriptreact", "vue" },
|
||||||
config = function()
|
config = function()
|
||||||
require('typescript-tools').setup {
|
require("typescript-tools").setup({
|
||||||
on_attach = function(client, bufnr)
|
on_attach = function(client, bufnr)
|
||||||
client.server_capabilities.documentFormattingProvider = false
|
local opts = { silent = true }
|
||||||
client.server_capabilities.documentRangeFormattingProvider = false
|
local keymap = vim.keymap
|
||||||
end,
|
opts.buffer = bufnr
|
||||||
filetypes = {
|
|
||||||
'javascript',
|
-- set keybinds
|
||||||
'javascriptreact',
|
opts.desc = "Show LSP references"
|
||||||
'typescript',
|
keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts)
|
||||||
'typescriptreact',
|
|
||||||
'vue',
|
opts.desc = "Go to declaration"
|
||||||
},
|
keymap.set("n", "gD", ":lua vim.lsp.buf.declaration", opts)
|
||||||
settings = {
|
|
||||||
tsserver_plugins = {
|
opts.desc = "Show LSP definitions"
|
||||||
'@vue/typescript-plugin',
|
keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts)
|
||||||
},
|
|
||||||
jsx_close_tag = {
|
opts.desc = "Show LSP implementations"
|
||||||
enable = true,
|
keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts)
|
||||||
filetypes = { 'javascriptreact', 'typescriptreact' },
|
|
||||||
},
|
opts.desc = "Show LSP type definitions"
|
||||||
},
|
keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts)
|
||||||
}
|
|
||||||
end,
|
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