create "organize imports" mapping for TS on lsp attach
This commit is contained in:
parent
7f67cabd57
commit
c43196a300
1 changed files with 13 additions and 3 deletions
|
|
@ -1,8 +1,18 @@
|
|||
vim.o.textwidth = 120
|
||||
|
||||
local function on_ts_ls_attach(ev)
|
||||
vim.keymap.set("n", "<leader>o", function()
|
||||
vim.lsp.buf.execute_command({ command = "_typescript.organizeImports", arguments = { vim.fn.expand("%:p") } })
|
||||
end, { desc = "Organize imports" })
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if not client then return end
|
||||
return client:exec_cmd({
|
||||
title = "Organize imports",
|
||||
command = "_typescript.organizeImports",
|
||||
arguments = { vim.api.nvim_buf_get_name(ev.buf) }
|
||||
}, { bufnr = ev.buf })
|
||||
end, { noremap = true, silent = true, buffer = ev.buf })
|
||||
end
|
||||
vim.api.nvim_create_autocmd("LspAttach", { callback = on_ts_ls_attach })
|
||||
|
||||
vim.keymap.set("n", "<leader>s", function()
|
||||
require("nvim-quick-switcher").toggle("tsx", "scss")
|
||||
end, { buffer = true })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue