mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
fix(typescript): don't hardcode values in lua table
When a user changes `vim.opt.shiftwidth` with some auto-command, it's not taken into account. Make `opts` a function, so that values get evaluated when `lspconfig` loads instead.
This commit is contained in:
parent
879e29504d
commit
b9563799be
1 changed files with 49 additions and 52 deletions
|
|
@ -13,62 +13,59 @@ return {
|
||||||
-- correctly setup lspconfig
|
-- correctly setup lspconfig
|
||||||
{
|
{
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
opts = {
|
opts = function(_, opts)
|
||||||
-- make sure mason installs the server
|
opts.servers.tsserver = {
|
||||||
servers = {
|
keys = {
|
||||||
---@type lspconfig.options.tsserver
|
{
|
||||||
tsserver = {
|
"<leader>co",
|
||||||
keys = {
|
function()
|
||||||
{
|
vim.lsp.buf.code_action({
|
||||||
"<leader>co",
|
apply = true,
|
||||||
function()
|
context = {
|
||||||
vim.lsp.buf.code_action({
|
only = { "source.organizeImports.ts" },
|
||||||
apply = true,
|
diagnostics = {},
|
||||||
context = {
|
},
|
||||||
only = { "source.organizeImports.ts" },
|
})
|
||||||
diagnostics = {},
|
end,
|
||||||
},
|
desc = "Organize Imports",
|
||||||
})
|
|
||||||
end,
|
|
||||||
desc = "Organize Imports",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"<leader>cR",
|
|
||||||
function()
|
|
||||||
vim.lsp.buf.code_action({
|
|
||||||
apply = true,
|
|
||||||
context = {
|
|
||||||
only = { "source.removeUnused.ts" },
|
|
||||||
diagnostics = {},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
desc = "Remove Unused Imports",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
settings = {
|
{
|
||||||
typescript = {
|
"<leader>cR",
|
||||||
format = {
|
function()
|
||||||
indentSize = vim.o.shiftwidth,
|
vim.lsp.buf.code_action({
|
||||||
convertTabsToSpaces = vim.o.expandtab,
|
apply = true,
|
||||||
tabSize = vim.o.tabstop,
|
context = {
|
||||||
},
|
only = { "source.removeUnused.ts" },
|
||||||
},
|
diagnostics = {},
|
||||||
javascript = {
|
},
|
||||||
format = {
|
})
|
||||||
indentSize = vim.o.shiftwidth,
|
end,
|
||||||
convertTabsToSpaces = vim.o.expandtab,
|
desc = "Remove Unused Imports",
|
||||||
tabSize = vim.o.tabstop,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
completions = {
|
|
||||||
completeFunctionCalls = true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
settings = {
|
||||||
},
|
typescript = {
|
||||||
|
format = {
|
||||||
|
indentSize = vim.o.shiftwidth,
|
||||||
|
convertTabsToSpaces = vim.o.expandtab,
|
||||||
|
tabSize = vim.o.tabstop,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
javascript = {
|
||||||
|
format = {
|
||||||
|
indentSize = vim.o.shiftwidth,
|
||||||
|
convertTabsToSpaces = vim.o.expandtab,
|
||||||
|
tabSize = vim.o.tabstop,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
completions = {
|
||||||
|
completeFunctionCalls = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"mfussenegger/nvim-dap",
|
"mfussenegger/nvim-dap",
|
||||||
optional = true,
|
optional = true,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue