Awesome
__ _ _ _ _ _
/ _(_) | ___ | | ___ ___ __ _| |_(_) ___ _ __
| |_| | |/ _ \ | |/ _ \ / __/ _` | __| |/ _ \| '_ \
| _| | | __/ | | (_) | (_| (_| | |_| | (_) | | | |
|_| |_|_|\___| |_|\___/ \___\__,_|\__|_|\___/|_| |_|
| Simple nvim plugin that copies the exact file location where the cursor is ยท written in lua ๐ผ |
1. Prerequisites ๐ฆ
Make sure to have the clipboard enabled in your nvim configuration:
Lua
-- clipboard
vim.opt.clipboard:append("unnamedplus")
Vimscript
" clipboard
set clipboard=unnamedplus
2. Installation โก๏ธ
Packer
use("diegoulloao/nvim-file-location")
Dein
call dein#call("diegoulloao/nvim-file-location")
Plug
Plug "diegoulloao/nvim-file-location"
3. Usage โจ
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 = "*",
})
mode [string]
- workdir:
pages/index.ts:25
- absolute:
/Users/diego/Desktop/next-js-app/pages/index.ts:25
add_line [boolean]
Let's take the workdir mode for this example:
true
:pages/index.ts:25
false
:pages/index.ts
add_column [boolean]
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
register [string]
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
Custom keymaps
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)
4. Integrations ๐
It's highly recommended to use it together with nvim-notify in order to get nice notifications ๐
5. Changelog ๐
All notable changes are listed here: changelog
diegoulloao ยท 2023