Very nice tips! It is good to see people working on neovim using native features. More built-in options below: On your first tip, it is more common to do it the other way around: Set the line or range with marks, and then copy or move it (e.g. :'a,'bt.) It is often the case that vimscript is more readable and easier to work with than its equivalent lua code. Even more so now with vim9 script. For accessing environment variables, it is enough to reference it with $ ($MACHINE). set formatprg=stylua would be enough to replicate the Lua formatter example. Telescope jump line is a good option, but it is easy to do it with :find (or any other custom function that opens files) -> :file still.md | :20 g CTRL-A is a visual selection mapping that increases the numbers sequentially.
Yes, go to my init file gist (link in video description) and look in the Telescope file. Alternatively grab it from here: gitter.im/nvim-telescope/community?at=6113b874025d436054c468e6
Great tips, thank you. To figure out the mapping of a key there's a shorter version: just us the map, imap, nmap, .. command followed by the key. E.g. imap . This will print what C-e is mapped to. There's also a telescope built-in to list and search the currently set up mappings. I find this variant helpful when I want to lookup the mappings of a plugin.
Great tips! thanks The code at 6:58 contains a bug when selecting something in the telescope picker .. here the fix if you want it ``` pickers = { find_files = { on_input_filter_cb = function(prompt) local find_colon = string.find(prompt, ":") if find_colon then local ret = string.sub(prompt, 1, find_colon - 1) vim.schedule(function() local prompt_bufnr = vim.api.nvim_get_current_buf() local state = action_state.get_current_picker(prompt_bufnr).previewer.state local lnum = tonumber(prompt:sub(find_colon + 1)) if type(lnum) == "number" then if state then local win = tonumber(state.winid) local bufnr = tonumber(state.bufnr) local line_count = vim.api.nvim_buf_line_count(bufnr) vim.api.nvim_win_set_cursor(win, { math.max(1, math.min(lnum, line_count)), 0 }) end end end) -- make sure we send the selected on to the attach_mappings local selection = action_state.get_selected_entry() if selection then ret = selection[1] end return { prompt = ret } end end, attach_mappings = function() actions.select_default:enhance({ post = function() local prompt = action_state.get_current_line() local find_colon = string.find(prompt, ":") if find_colon then local lnum = tonumber(prompt:sub(find_colon + 1)) vim.api.nvim_win_set_cursor(0, { lnum, 0 }) end end, }) return true end, }, }, ```
I can definitely see the value in that but most stuff, key wise, is now (finally!) in my head so not sure I’d want the extra code in my config. Do you have it set for normal motion commands or just the kind of things you have mapped on the leader?
@@benfrainuk it automatically picks up everything! Custom mappings and built in one's. It also shows you what's in your marks and registers too. So it's a really practical one I find. 🙂
@@benfrainuk your welcome it has a lot of advantage over any formatter and i quit from using vim or neovim for the work and know using emacs it is worth to try it that because have problem with rust and lsp even clang so emacs know my text editor
so many great tips that I haven't seen anywhere else. thank you Ben!
Oh, that’s great to hear. Got a ‘Volume Two’ written too - just need to get it recorded 👍
Amazing neovim tips that aren't super common, love it! Keep up the great vids :)
this is the most practical nvim content that I came across.
Thank you for sharing, looking forward for more :)
Thanks Narwash 👍 definitely more on the way!
Very nice tips! It is good to see people working on neovim using native features. More built-in options below:
On your first tip, it is more common to do it the other way around: Set the line or range with marks, and then copy or move it (e.g. :'a,'bt.)
It is often the case that vimscript is more readable and easier to work with than its equivalent lua code. Even more so now with vim9 script. For accessing environment variables, it is enough to reference it with $ ($MACHINE).
set formatprg=stylua would be enough to replicate the Lua formatter example.
Telescope jump line is a good option, but it is easy to do it with :find (or any other custom function that opens files) -> :file still.md | :20
g CTRL-A is a visual selection mapping that increases the numbers sequentially.
Thanks Ben. Really enjoyed the vid and look forward to trying out those tips!
Thanks Diarmaid! Appreciate it 👍
Some cool tips, plenty I did not know so yes please do more.
Excellent Will. Thanks. Will do!
hi ben, tried my best to find that resource you highlighted for the nvim jump to line with colon number using telescope (segment
why did half my comment disappear?
long story short, do you have the code snippet available for jumping to a line number with vim telescope? I cant find it.
Yes, go to my init file gist (link in video description) and look in the Telescope file. Alternatively grab it from here: gitter.im/nvim-telescope/community?at=6113b874025d436054c468e6
Great tips, thank you. To figure out the mapping of a key there's a shorter version: just us the map, imap, nmap, .. command followed by the key. E.g. imap . This will print what C-e is mapped to.
There's also a telescope built-in to list and search the currently set up mappings. I find this variant helpful when I want to lookup the mappings of a plugin.
Can’t believe I missed the Telescope built-in for mappings! Thanks 👍
Great tips. I wonder what color scheme are you using. Thanks
Hi Marian, it’s Tokyo Night: github.com/folke/tokyonight.nvim
Great tips! thanks
The code at 6:58 contains a bug when selecting something in the telescope picker .. here the fix if you want it
```
pickers = {
find_files = {
on_input_filter_cb = function(prompt)
local find_colon = string.find(prompt, ":")
if find_colon then
local ret = string.sub(prompt, 1, find_colon - 1)
vim.schedule(function()
local prompt_bufnr = vim.api.nvim_get_current_buf()
local state = action_state.get_current_picker(prompt_bufnr).previewer.state
local lnum = tonumber(prompt:sub(find_colon + 1))
if type(lnum) == "number" then
if state then
local win = tonumber(state.winid)
local bufnr = tonumber(state.bufnr)
local line_count = vim.api.nvim_buf_line_count(bufnr)
vim.api.nvim_win_set_cursor(win, { math.max(1, math.min(lnum, line_count)), 0 })
end
end
end)
-- make sure we send the selected on to the attach_mappings
local selection = action_state.get_selected_entry()
if selection then
ret = selection[1]
end
return { prompt = ret }
end
end,
attach_mappings = function()
actions.select_default:enhance({
post = function()
local prompt = action_state.get_current_line()
local find_colon = string.find(prompt, ":")
if find_colon then
local lnum = tonumber(prompt:sub(find_colon + 1))
vim.api.nvim_win_set_cursor(0, { lnum, 0 })
end
end,
})
return true
end,
},
},
```
if that problem of lsp with lua lsp you can use any vim package manager to download and install what you want even lsp
I recommend the whichkey plugin
I can definitely see the value in that but most stuff, key wise, is now (finally!) in my head so not sure I’d want the extra code in my config. Do you have it set for normal motion commands or just the kind of things you have mapped on the leader?
@@benfrainuk it automatically picks up everything! Custom mappings and built in one's. It also shows you what's in your marks and registers too. So it's a really practical one I find. 🙂
Cool tips. Netrw can be toggled by default with -
Use null-ls and it will work with alot of language instead of formater
Thanks, swapped to null-ls now. Seems to keep the change list in tact now too
@@benfrainuk your welcome it has a lot of advantage over any formatter and i quit from using vim or neovim for the work and know using emacs it is worth to try it that because have problem with rust and lsp even clang so emacs know my text editor
The back and fourth of the screen-capture and your persona is very distracting It makes very difficult to concentrate on what are you explaining
Yes. I’m doing another of these type soon and will keep it all on the code with just a head shot down the corner (and bigger text on screen).