[TypeScript] Enable all LSP functions
This commit is contained in:
parent
1ac43ff80c
commit
6332f7b770
@ -1,30 +1,79 @@
|
||||
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)
|
||||
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,
|
||||
"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