__ _ _ _ _ _
/ _(_) | ___ | | ___ ___ __ _| |_(_) ___ _ __
| |_| | |/ _ \ | |/ _ \ / __/ _` | __| |/ _ \| '_ \
| _| | | __/ | | (_) | (_| (_| | |_| | (_) | | | |
|_| |_|_|\___| |_|\___/ \___\__,_|\__|_|\___/|_| |_|
| Simple nvim plugin that copies the exact file location where the cursor is · written in lua 😼 |
Make sure to have the clipboard enabled in your nvim configuration:
Lua
-- clipboard
vim.opt.clipboard:append("unnamedplus")
Vimscript
" clipboard
set clipboard=unnamedplus
Packer
use("diegoulloao/nvim-file-location")
Dein
call dein#call("diegoulloao/nvim-file-location")
Plug
Plug "diegoulloao/nvim-file-location"
Call the setup function passing your custom options inside the table if necessary:
Lua
-- require plugin
local status, nvim_file_location = pcall(require, "nvim-file-location")
if not status then
return
end
-- custom config
nvim_file_location.setup({
keymap = "<leader>L",
mode = "workdir", -- options: workdir | absolute
add_line = true,
add_column = false,
default_register = "*",
})
- workdir:
pages/index.ts:25
- absolute:
/Users/diego/Desktop/next-js-app/pages/index.ts:25
Let's take the workdir mode for this example:
true
:pages/index.ts:25
false
:pages/index.ts
It works only if add_line
is true
Let's take the workdir mode for this example:
true
:pages/index.ts:25:11
false
:pages/index.ts:25
The register to use (default is the global system register "*"
)
Defaults options:
{
keymap = "<leader>L",
mode = "workdir",
add_line = true,
add_column = false,
default_register = "*",
}
Vimscript
lua << EOF
require("nvim-file-location").setup()
EOF
To add keymaps for differents modes do it like:
Lua
vim.keymap.set("n", "<leader>fl", "<cmd>lua NvimFileLocation.copy_file_location('absolute', true, false)<cr>")
Vimscript
nnoremap <leader>fl :lua NvimFileLocation.copy_file_location("absolute", true, false)<cr>
Where params are (optional):
NvimFileLocation.copy_file_location(mode, add_line, add_column, register)
It's highly recommended to use it together with nvim-notify in order to get nice notifications 😍
All notable changes are listed here: changelog
diegoulloao · 2023