♻️ refactor(nvim): typescript-extended extra big changes
added typescript-tools. created variable to choose between typescript-tools (which has some things I need to work on like inlay hints not working or disabling when inside a deno based project) or lsp-config tsserver
This commit is contained in:
parent
073e08a580
commit
53953488fe
1 changed files with 48 additions and 26 deletions
|
@ -1,14 +1,5 @@
|
||||||
local source_action = function(name)
|
local ts_server_activated = true
|
||||||
return function()
|
local ft = { "typescript", "typescriptreact", "javascript", "javascriptreact" }
|
||||||
vim.lsp.buf.code_action({
|
|
||||||
apply = true,
|
|
||||||
context = {
|
|
||||||
only = { string.format("source.%s.ts", name) },
|
|
||||||
diagnostics = {},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local inlayHints = {
|
local inlayHints = {
|
||||||
includeInlayParameterNameHints = "all",
|
includeInlayParameterNameHints = "all",
|
||||||
|
@ -21,17 +12,16 @@ local inlayHints = {
|
||||||
includeInlayEnumMemberValueHints = true,
|
includeInlayEnumMemberValueHints = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function denoConfigExists()
|
local source_action = function(name)
|
||||||
local configs = { "deno.json", "deno.jsonc" }
|
return function()
|
||||||
local root = require("lazyvim.util.root").get()
|
vim.lsp.buf.code_action({
|
||||||
|
apply = true,
|
||||||
for _, config in ipairs(configs) do
|
context = {
|
||||||
if vim.fn.filereadable(root .. "/" .. config) == 1 then
|
only = { string.format("source.%s.ts", name) },
|
||||||
return true
|
diagnostics = {},
|
||||||
|
},
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -49,6 +39,7 @@ return {
|
||||||
opts = {
|
opts = {
|
||||||
servers = {
|
servers = {
|
||||||
tsserver = {
|
tsserver = {
|
||||||
|
enabled = ts_server_activated,
|
||||||
init_options = {
|
init_options = {
|
||||||
preferences = {
|
preferences = {
|
||||||
disableSuggestions = true,
|
disableSuggestions = true,
|
||||||
|
@ -82,13 +73,44 @@ return {
|
||||||
},
|
},
|
||||||
denols = {},
|
denols = {},
|
||||||
},
|
},
|
||||||
setup = {
|
|
||||||
tsserver = function(_, opts)
|
|
||||||
-- Disable tsserver if denols is present
|
|
||||||
return denoConfigExists()
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"pmizio/typescript-tools.nvim",
|
||||||
|
dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
|
||||||
|
enabled = not ts_server_activated,
|
||||||
|
ft = ft,
|
||||||
|
opts = {
|
||||||
|
cmd = { "typescript-language-server", "--stdio" },
|
||||||
|
settings = {
|
||||||
|
code_lens = "all",
|
||||||
|
expose_as_code_action = "all",
|
||||||
|
tsserver_plugins = {
|
||||||
|
"@styled/typescript-styled-plugin",
|
||||||
|
},
|
||||||
|
tsserver_file_preferences = {
|
||||||
|
completions = {
|
||||||
|
completeFunctionCalls = true,
|
||||||
|
},
|
||||||
|
init_options = {
|
||||||
|
preferences = {
|
||||||
|
disableSuggestions = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
includeInlayParameterNameHints = "all",
|
||||||
|
includeInlayEnumMemberValueHints = true,
|
||||||
|
includeInlayFunctionLikeReturnTypeHints = true,
|
||||||
|
includeInlayFunctionParameterTypeHints = true,
|
||||||
|
includeInlayPropertyDeclarationTypeHints = true,
|
||||||
|
includeInlayVariableTypeHints = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
keys = {
|
||||||
|
{ "<leader>co", ft = ft, "<cmd>TSToolsOrganizeImports<cr>", desc = "Organize Imports" },
|
||||||
|
{ "<leader>cR", ft = ft, "<cmd>TSToolsRemoveUnusedImports<cr>", desc = "Remove Unused Imports" },
|
||||||
|
{ "<leader>cM", ft = ft, "<cmd>TSToolsAddMissingImports<cr>", desc = "Add Missing Imports" },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
|
Loading…
Add table
Reference in a new issue