Skip to content

Commit

Permalink
chore: custom commands for organize import and telescope changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham-cpp committed Dec 19, 2024
1 parent 9019c54 commit aa72bb4
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 35 deletions.
3 changes: 1 addition & 2 deletions .config/nvim-astro/lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"guess-indent.nvim": { "branch": "main", "commit": "6cd61f7a600bb756e558627cd2e740302c58e32d" },
"gx.nvim": { "branch": "main", "commit": "b01db725a001e4215f363159fc04727f6fde0a1c" },
"heirline.nvim": { "branch": "master", "commit": "cc359b628266cb9a84b2d71c883f2b99e16473a0" },
"hererocks": { "branch": "master", "commit": "c9c5444dea1e07e005484014a8231aa667be30b6" },
"img-clip.nvim": { "branch": "main", "commit": "5ff183655ad98b5fc50c55c66540375bbd62438c" },
"indent-blankline.nvim": { "branch": "master", "commit": "259357fa4097e232730341fa60988087d189193a" },
"lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" },
Expand Down Expand Up @@ -102,13 +101,13 @@
"smart-splits.nvim": { "branch": "master", "commit": "00fba7a0e912a8d82da91a3b6b11d641fa500bd8" },
"telescope-egrepify.nvim": { "branch": "master", "commit": "a8070970a661330c4e00450d25f874f6c2b00af9" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
"telescope-zf-native.nvim": { "branch": "master", "commit": "5721be27df11a19b9cd95e6a4887f16f26599802" },
"telescope.nvim": { "branch": "0.1.x", "commit": "2eca9ba22002184ac05eddbe47a7fe2d5a384dfc" },
"template-string.nvim": { "branch": "main", "commit": "419bfb2e4d5f0e6ddd0d4435f85b69da0d88d524" },
"todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" },
"toggleterm.nvim": { "branch": "main", "commit": "022ff5594acccc8d90d2e46dc43994f7722ebdf7" },
"ts-error-translator.nvim": { "branch": "main", "commit": "47e5ba89f71b9e6c72eaaaaa519dd59bd6897df4" },
"tsc.nvim": { "branch": "main", "commit": "59abb6f3f24a3ca80708f694af4e2b727a1a3211" },
"undotree": { "branch": "master", "commit": "78b5241191852ffa9bb5da5ff2ee033160798c3b" },
"venv-selector.nvim": { "branch": "regexp", "commit": "e82594274bf7b54387f9a2abe65f74909ac66e97" },
"vim-dadbod": { "branch": "master", "commit": "f740950d0703099e0f172016f10e0e39f50fd0ba" },
"vim-dadbod-completion": { "branch": "master", "commit": "04485bfb53a629423233a4178d71cd4f8abf7406" },
Expand Down
52 changes: 52 additions & 0 deletions .config/nvim-astro/lua/plugins/astrolsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,38 @@ return {
},
},
},
commands = {
ImportsOrganize = {
function()
vim.lsp.buf.code_action {
context = { only = { "source.organizeImports" } },
apply = true,
}
end,
cond = "textDocument/codeAction",
desc = "Organize Imports",
},
ImportsRemove = {
function()
vim.lsp.buf.code_action {
context = { only = { "source.removeUnused" } },
apply = true,
}
end,
cond = "textDocument/codeAction",
desc = "Remove Unused Imports",
},
FixAll = {
function()
vim.lsp.buf.code_action {
context = { only = { "source.fixAll" } },
apply = true,
}
end,
cond = "textDocument/codeAction",
desc = "Fix All fixable diagnostics",
},
},
-- mappings to be set up on attaching of a language server
mappings = {
n = {
Expand Down Expand Up @@ -218,6 +250,26 @@ return {
vim.lsp.buf.format,
desc = "Format buffer",
},
["<leader>lo"] = {
function()
vim.lsp.buf.code_action {
context = { only = { "source.organizeImports" } },
apply = true,
}
end,
desc = "Oraganize imports",
cond = "textDocument/codeAction",
},
["<leader>lF"] = {
function()
vim.lsp.buf.code_action {
context = { only = { "source.fixAll" } },
apply = true,
}
end,
desc = "Fix All",
cond = "textDocument/codeAction",
},
},
i = {
["<C-k>"] = {
Expand Down
68 changes: 35 additions & 33 deletions .config/nvim-astro/lua/plugins/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,27 @@ return {
},
},
},
keys = {
{ "<c-p>", function() require("telescope.builtin").find_files() end, desc = "Find files" },
{
"<leader>fn",
function() require("telescope.builtin").find_files { cwd = vim.fn.stdpath "config" } end,
desc = "Neovim Config",
},
{
"<leader>fd",
function()
require("telescope.builtin").find_files { cwd = vim.fn.expand "~/Documents/dotfiles", hidden = true }
end,
desc = "Dotfiles",
},
{
"<leader>fl",
function() require("telescope.builtin").find_files { cwd = vim.fn.stdpath "data" .. "/lazy" } end,
desc = "All Plugins",
},
{ "<leader>fN", "<cmd>Telescope notify<CR>", desc = "Notification" },
},
},
{
"fdschmidt93/telescope-egrepify.nvim",
Expand All @@ -78,25 +99,6 @@ return {
mappings = {
n = {
["<Leader>fs"] = { "<Cmd>Telescope egrepify<CR>", desc = "Search" },
["<c-p>"] = { function() require("telescope.builtin").find_files() end, desc = "Find files" },
["<leader>fn"] = {
function() require("telescope.builtin").find_files { cwd = vim.fn.stdpath "config" } end,
desc = "Neovim Config",
},
["<leader>fd"] = {
function()
require("telescope.builtin").find_files {
cwd = vim.fn.expand "~/Documents/dotfiles",
hidden = true,
}
end,
desc = "Dotfiles",
},
["<leader>fl"] = {
function() require("telescope.builtin").find_files { cwd = vim.fn.stdpath "data" .. "lazy" } end,
desc = "All Plugins",
},
["<leader>fN"] = { "<cmd>Telescope notify<CR>", desc = "Notification" },
},
},
},
Expand All @@ -106,18 +108,18 @@ return {
},
},
},
{
"natecraddock/telescope-zf-native.nvim",
lazy = true,
specs = {
{
"nvim-telescope/telescope.nvim",
dependencies = {
"natecraddock/telescope-zf-native.nvim",
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make", enabled = false },
},
opts = function() require("telescope").load_extension "zf-native" end,
},
},
},
-- {
-- "natecraddock/telescope-zf-native.nvim",
-- lazy = true,
-- specs = {
-- {
-- "nvim-telescope/telescope.nvim",
-- dependencies = {
-- "natecraddock/telescope-zf-native.nvim",
-- { "nvim-telescope/telescope-fzf-native.nvim", build = "make", enabled = false },
-- },
-- opts = function() require("telescope").load_extension "zf-native" end,
-- },
-- },
-- },
}
40 changes: 40 additions & 0 deletions .config/nvim/lua/plugins/config/astrolsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,36 @@ M.opts = {
cond = 'textDocument/formatting',
desc = 'Format file with LSP',
},
ImportsOrganize = {
function()
vim.lsp.buf.code_action({
context = { only = { 'source.organizeImports' } },
apply = true,
})
end,
cond = 'textDocument/codeAction',
desc = 'Organize Imports',
},
ImportsRemove = {
function()
vim.lsp.buf.code_action({
context = { only = { 'source.removeUnused' } },
apply = true,
})
end,
cond = 'textDocument/codeAction',
desc = 'Remove Unused Imports',
},
FixAll = {
function()
vim.lsp.buf.code_action({
context = { only = { 'source.fixAll' } },
apply = true,
})
end,
cond = 'textDocument/codeAction',
desc = 'Fix All fixable diagnostics',
},
},
capabilities = {
textDocument = { foldingRange = { dynamicRegistration = false, lineFoldingOnly = true } },
Expand Down Expand Up @@ -83,6 +113,16 @@ M.opts = {
desc = 'Goto definition',
cond = 'textDocument/definition',
},
['<leader>lf'] = {
function()
vim.lsp.buf.code_action({
context = { only = { 'source.fixAll' } },
apply = true,
})
end,
desc = 'Fix All',
cond = 'textDocument/codeAction',
},
['<leader>lo'] = {
function()
vim.lsp.buf.code_action({
Expand Down

0 comments on commit aa72bb4

Please sign in to comment.