mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 16:41:43 +05:30
NVIM: Typescript-only keymaps added only when ts files are loaded
This commit is contained in:
27
common/.config/nvim/lua/config/filetype-based-keymaps.lua
Normal file
27
common/.config/nvim/lua/config/filetype-based-keymaps.lua
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
-- Enable spell check on markdown and text files
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
group = vim.api.nvim_create_augroup("keymaps-csharp-omnisharp", { clear = true }),
|
||||||
|
pattern = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx", "vue", "svelte", "astro" },
|
||||||
|
callback = function()
|
||||||
|
-- vim.keymap.set({ "n", "v" }, "<leader>ca", "<cmd>OmniSharpGetCodeActions<CR>", { desc = "Code: Code Actions (C#)" })
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>co", function()
|
||||||
|
vim.lsp.buf.code_action({
|
||||||
|
apply = true,
|
||||||
|
context = {
|
||||||
|
only = { "source.organizeImports.ts" },
|
||||||
|
diagnostics = {},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end, { desc = "Code: Typescript: Organize Imports" })
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>cO", function()
|
||||||
|
vim.lsp.buf.code_action({
|
||||||
|
apply = true,
|
||||||
|
context = {
|
||||||
|
only = { "source.removeUnused.ts" },
|
||||||
|
diagnostics = {},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end, { desc = "Code: Typescript: Remove Unused Imports" })
|
||||||
|
end,
|
||||||
|
nested = true,
|
||||||
|
})
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
require("config.keymaps")
|
require("config.keymaps")
|
||||||
require("config.options")
|
require("config.options")
|
||||||
require("config.autocmd")
|
require("config.autocmd")
|
||||||
|
require("config.filetype-based-keymaps")
|
||||||
require("config.vim_plugin_config")
|
require("config.vim_plugin_config")
|
||||||
|
|||||||
@@ -152,34 +152,6 @@ return {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
keys = {
|
|
||||||
{
|
|
||||||
"<leader>cu",
|
|
||||||
function()
|
|
||||||
vim.lsp.buf.code_action({
|
|
||||||
apply = true,
|
|
||||||
context = {
|
|
||||||
only = { "source.organizeImports.ts" },
|
|
||||||
diagnostics = {},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
desc = "Typescript: Organize Imports",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"<leader>cU",
|
|
||||||
function()
|
|
||||||
vim.lsp.buf.code_action({
|
|
||||||
apply = true,
|
|
||||||
context = {
|
|
||||||
only = { "source.removeUnused.ts" },
|
|
||||||
diagnostics = {},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
desc = "Typescript: Remove Unused Imports",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user