mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
feat(typescript-lang): Add missing import keymap
This commit is contained in:
parent
879e29504d
commit
a9919f04bf
1 changed files with 19 additions and 18 deletions
|
|
@ -1,3 +1,15 @@
|
||||||
|
local source_action = function(name)
|
||||||
|
return function()
|
||||||
|
vim.lsp.buf.code_action({
|
||||||
|
apply = true,
|
||||||
|
context = {
|
||||||
|
only = { string.format("source.%s.ts", name) },
|
||||||
|
diagnostics = {},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
||||||
-- add typescript to treesitter
|
-- add typescript to treesitter
|
||||||
|
|
@ -21,28 +33,17 @@ return {
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
"<leader>co",
|
"<leader>co",
|
||||||
function()
|
source_action("organizeImports"),
|
||||||
vim.lsp.buf.code_action({
|
|
||||||
apply = true,
|
|
||||||
context = {
|
|
||||||
only = { "source.organizeImports.ts" },
|
|
||||||
diagnostics = {},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
desc = "Organize Imports",
|
desc = "Organize Imports",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"<leader>cM",
|
||||||
|
source_action("addMissingImports"),
|
||||||
|
desc = "Add Missing Imports",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"<leader>cR",
|
"<leader>cR",
|
||||||
function()
|
source_action("removeUnused"),
|
||||||
vim.lsp.buf.code_action({
|
|
||||||
apply = true,
|
|
||||||
context = {
|
|
||||||
only = { "source.removeUnused.ts" },
|
|
||||||
diagnostics = {},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
desc = "Remove Unused Imports",
|
desc = "Remove Unused Imports",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue