diff --git a/lua/custom/fzf_lua.lua b/lua/custom/fzf_lua.lua index b520536..a48381f 100644 --- a/lua/custom/fzf_lua.lua +++ b/lua/custom/fzf_lua.lua @@ -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", "ff", function() fzf_lua.files() end, { desc = "FZF: find files in cwd" }) keymap("n", "fg", function() fzf_lua.live_grep() end, { desc = "FZF: find string in cwd" }) keymap("n", "fs", function() fzf_lua.grep_cword() end, { desc = "FZF: find string under cursor" }) @@ -115,6 +124,8 @@ keymap('n', 'fp', live_grep_with_glob, { desc = 'Live grep with glob pat keymap('n', 'fcp', live_grep_in_current_dir, { desc = 'Live grep in current directory' }) keymap('n', 'ccp', copy_file_path_and_position, { desc = "Copy cursor position" }) keymap('n', 'ccd', copy_current_file_path, { desc = 'Copy current file path' }) +keymap('n', 'ccf', copy_filename, { desc = 'Copy current file path' }) + keymap('n', 'fq', live_grep_in_quick_fix_list_files, { desc = "Live grep in quickfix files" }) keymap('n', 'fcf', function() @@ -128,8 +139,9 @@ end, { desc = "Live grep in current file" }) keymap("n", "fml", function() fzf_lua.marks() end, { desc = "FZF: find marks list" }) keymap("n", "fmp", function() fzf_lua.man_pages() end, { desc = "FZF: find available man pages" }) keymap("n", "fds", function() fzf_lua.lsp_document_symbols() end, { desc = "Grep: Document symbols" }) +keymap("n", "ft", function() fzf_lua.tabs() end, { desc = "Pick opened tabs" }) -keymap("n", "ft", function() +keymap("n", "fn", function() fzf_lua.grep({ prompt = 'Todo❯ ', search = 'TODO|FIXME|XXX|HACK|BUG|NOTE|PERF|OPTIMIZE', diff --git a/lua/custom/lsp.lua b/lua/custom/lsp.lua index 2f6d1ac..b2e71ad 100644 --- a/lua/custom/lsp.lua +++ b/lua/custom/lsp.lua @@ -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", "Telescope lsp_references", opts) + keymap.set("n", "gR", string.format("%s lsp_references", 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", "Telescope lsp_definitions", opts) + keymap.set("n", "gd", string.format("%s lsp_definitions", picker), opts) -- show lsp implementations opts.desc = "Show LSP implementations" - keymap.set("n", "gi", "Telescope lsp_implementations", opts) + keymap.set("n", "gi", string.format("%s lsp_implementations", picker), opts) -- show lsp type definitions opts.desc = "Show LSP type definitions" - keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) + keymap.set("n", "glt", string.format("%s lsp_type_definitions", 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", "D", "Telescope diagnostics bufnr=0", opts) + keymap.set("n", "D", string.format("%s diagnostics bufnr=0", picker), opts) -- show diagnostics for line opts.desc = "Show line diagnostics" diff --git a/lua/custom/telescope.lua b/lua/custom/telescope.lua index 1006c9a..dc69dba 100644 --- a/lua/custom/telescope.lua +++ b/lua/custom/telescope.lua @@ -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", "fds", builtin.lsp_document_symbols, { desc = "Grep: Doc keymap.set('n', 'fp', live_grep_with_glob, { desc = 'Live grep with glob pattern' }) keymap.set('n', 'fcp', live_grep_in_current_dir, { desc = 'Live grep in current directory' }) keymap.set('n', 'ccp', copy_file_path_and_position, { desc = "Copy cursor position" }) +keymap.set('n', 'ccf', copy_filename, { desc = "Copy only filename" }) keymap.set('n', 'ccd', copy_current_file_path, { desc = 'Live grep in current directory' }) keymap.set('n', 'fq', live_grep_in_quick_fix_list_files, { desc = "Live grep in quickfix files" }) keymap.set('n', 'fa', find_files_with_hidden_included, { desc = "Find all files (hidden + no ignore)" })