Some refactoring
This commit is contained in:
parent
87c56f266a
commit
1326308b68
3 changed files with 29 additions and 7 deletions
|
|
@ -99,10 +99,19 @@ local function find_all_files_including_hidden()
|
|||
)
|
||||
end
|
||||
|
||||
-- Function for getting filename and copy it to + buffer
|
||||
local function copy_filename()
|
||||
local filepath = vim.fn.expand('%:t')
|
||||
local output = string.format("%s", filepath)
|
||||
vim.fn.setreg("+", output)
|
||||
print("Copied: " .. output)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command('FzfLuaGrepGlob', live_grep_with_glob, {})
|
||||
|
||||
local keymap = vim.keymap.set
|
||||
|
||||
|
||||
keymap("n", "<leader>ff", function() fzf_lua.files() end, { desc = "FZF: find files in cwd" })
|
||||
keymap("n", "<leader>fg", function() fzf_lua.live_grep() end, { desc = "FZF: find string in cwd" })
|
||||
keymap("n", "<leader>fs", function() fzf_lua.grep_cword() end, { desc = "FZF: find string under cursor" })
|
||||
|
|
@ -115,6 +124,8 @@ keymap('n', '<leader>fp', live_grep_with_glob, { desc = 'Live grep with glob pat
|
|||
keymap('n', '<leader>fcp', live_grep_in_current_dir, { desc = 'Live grep in current directory' })
|
||||
keymap('n', '<leader>ccp', copy_file_path_and_position, { desc = "Copy cursor position" })
|
||||
keymap('n', '<leader>ccd', copy_current_file_path, { desc = 'Copy current file path' })
|
||||
keymap('n', '<leader>ccf', copy_filename, { desc = 'Copy current file path' })
|
||||
|
||||
keymap('n', '<leader>fq', live_grep_in_quick_fix_list_files, { desc = "Live grep in quickfix files" })
|
||||
|
||||
keymap('n', '<leader>fcf', function()
|
||||
|
|
@ -128,8 +139,9 @@ end, { desc = "Live grep in current file" })
|
|||
keymap("n", "<leader>fml", function() fzf_lua.marks() end, { desc = "FZF: find marks list" })
|
||||
keymap("n", "<leader>fmp", function() fzf_lua.man_pages() end, { desc = "FZF: find available man pages" })
|
||||
keymap("n", "<leader>fds", function() fzf_lua.lsp_document_symbols() end, { desc = "Grep: Document symbols" })
|
||||
keymap("n", "<leader>ft", function() fzf_lua.tabs() end, { desc = "Pick opened tabs" })
|
||||
|
||||
keymap("n", "<leader>ft", function()
|
||||
keymap("n", "<leader>fn", function()
|
||||
fzf_lua.grep({
|
||||
prompt = 'Todo❯ ',
|
||||
search = 'TODO|FIXME|XXX|HACK|BUG|NOTE|PERF|OPTIMIZE',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
-- Using vim.lsp.config() instead of require('lspconfig') (nvim-lspconfig >= 0.11)
|
||||
|
||||
local keymap = vim.keymap
|
||||
local picker = "FzfLua"
|
||||
|
||||
local capabilities = nil
|
||||
if pcall(require, "cmp_nvim_lsp") then
|
||||
|
|
@ -28,7 +29,7 @@ local servers = {
|
|||
init_options = {
|
||||
settings = {
|
||||
-- Ruff language server settings go here
|
||||
logLevel = "debug",
|
||||
logLevel = "error",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -167,7 +168,7 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||
-- set keybinds
|
||||
-- show definition, references
|
||||
opts.desc = "Show LSP references"
|
||||
keymap.set("n", "gR", "<cmd>Telescope lsp_references<CR>", opts)
|
||||
keymap.set("n", "gR", string.format("<cmd>%s lsp_references<CR>", picker), opts)
|
||||
|
||||
-- go to declaration
|
||||
opts.desc = "Go to declaration"
|
||||
|
|
@ -175,15 +176,15 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||
|
||||
-- show lsp definitions
|
||||
opts.desc = "Show LSP definitions"
|
||||
keymap.set("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts)
|
||||
keymap.set("n", "gd", string.format("<cmd>%s lsp_definitions<CR>", picker), opts)
|
||||
|
||||
-- show lsp implementations
|
||||
opts.desc = "Show LSP implementations"
|
||||
keymap.set("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts)
|
||||
keymap.set("n", "gi", string.format("<cmd>%s lsp_implementations<CR>", picker), opts)
|
||||
|
||||
-- show lsp type definitions
|
||||
opts.desc = "Show LSP type definitions"
|
||||
keymap.set("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts)
|
||||
keymap.set("n", "glt", string.format("<cmd>%s lsp_type_definitions<CR>", picker), opts)
|
||||
|
||||
-- see available code actions, in visual mode will apply to selection
|
||||
opts.desc = "See available code actions"
|
||||
|
|
@ -195,7 +196,7 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||
|
||||
-- show diagnostics for file
|
||||
opts.desc = "Show buffer diagnostics"
|
||||
keymap.set("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts)
|
||||
keymap.set("n", "<leader>D", string.format("<cmd>%s diagnostics bufnr=0<CR>", picker), opts)
|
||||
|
||||
-- show diagnostics for line
|
||||
opts.desc = "Show line diagnostics"
|
||||
|
|
|
|||
|
|
@ -71,6 +71,14 @@ local function copy_file_path_and_position()
|
|||
print("Copied: " .. output)
|
||||
end
|
||||
|
||||
-- Function for getting filename and copy it to + buffer
|
||||
local function copy_filename()
|
||||
local filepath = vim.fn.expand('%:t')
|
||||
local output = string.format("%s", filepath)
|
||||
vim.fn.setreg("+", output)
|
||||
print("Copied: " .. output)
|
||||
end
|
||||
|
||||
|
||||
local builtin = require("telescope.builtin")
|
||||
local keymap = vim.keymap
|
||||
|
|
@ -109,6 +117,7 @@ keymap.set("n", "<leader>fds", builtin.lsp_document_symbols, { desc = "Grep: Doc
|
|||
keymap.set('n', '<leader>fp', live_grep_with_glob, { desc = 'Live grep with glob pattern' })
|
||||
keymap.set('n', '<leader>fcp', live_grep_in_current_dir, { desc = 'Live grep in current directory' })
|
||||
keymap.set('n', '<leader>ccp', copy_file_path_and_position, { desc = "Copy cursor position" })
|
||||
keymap.set('n', '<leader>ccf', copy_filename, { desc = "Copy only filename" })
|
||||
keymap.set('n', '<leader>ccd', copy_current_file_path, { desc = 'Live grep in current directory' })
|
||||
keymap.set('n', '<leader>fq', live_grep_in_quick_fix_list_files, { desc = "Live grep in quickfix files" })
|
||||
keymap.set('n', '<leader>fa', find_files_with_hidden_included, { desc = "Find all files (hidden + no ignore)" })
|
||||
|
|
|
|||
Loading…
Reference in a new issue