Neovim - Power Tips: Volume 1

Sdílet
Vložit
  • čas přidán 12. 09. 2024

Komentáře • 29

  • @rsmith31416
    @rsmith31416 Před 2 lety +4

    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.

  • @_jdfx
    @_jdfx Před rokem +1

    so many great tips that I haven't seen anywhere else. thank you Ben!

    • @benfrainuk
      @benfrainuk  Před rokem +1

      Oh, that’s great to hear. Got a ‘Volume Two’ written too - just need to get it recorded 👍

  • @stephenbrown-bourne465
    @stephenbrown-bourne465 Před 2 lety +1

    Amazing neovim tips that aren't super common, love it! Keep up the great vids :)

  • @narwashius1176
    @narwashius1176 Před 2 lety

    this is the most practical nvim content that I came across.
    Thank you for sharing, looking forward for more :)

    • @benfrainuk
      @benfrainuk  Před 2 lety +1

      Thanks Narwash 👍 definitely more on the way!

  • @JanChristophEbersbach
    @JanChristophEbersbach Před 2 lety

    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.

    • @benfrainuk
      @benfrainuk  Před 2 lety +1

      Can’t believe I missed the Telescope built-in for mappings! Thanks 👍

  • @diarmaidmac2149
    @diarmaidmac2149 Před 3 lety

    Thanks Ben. Really enjoyed the vid and look forward to trying out those tips!

    • @benfrainuk
      @benfrainuk  Před 3 lety

      Thanks Diarmaid! Appreciate it 👍

  • @willadams6217
    @willadams6217 Před 3 lety

    Some cool tips, plenty I did not know so yes please do more.

  • @kimnielsen7818
    @kimnielsen7818 Před rokem +1

    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,
    },
    },
    ```

  • @Brazen_Braden
    @Brazen_Braden Před 2 lety +1

    hi ben, tried my best to find that resource you highlighted for the nvim jump to line with colon number using telescope (segment

    • @Brazen_Braden
      @Brazen_Braden Před 2 lety

      why did half my comment disappear?

    • @Brazen_Braden
      @Brazen_Braden Před 2 lety

      long story short, do you have the code snippet available for jumping to a line number with vim telescope? I cant find it.

    • @benfrainuk
      @benfrainuk  Před 2 lety +1

      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

  • @mvpopuk
    @mvpopuk Před 2 lety

    Great tips. I wonder what color scheme are you using. Thanks

    • @benfrainuk
      @benfrainuk  Před 2 lety +1

      Hi Marian, it’s Tokyo Night: github.com/folke/tokyonight.nvim

  • @user-xu9zx9fd7n
    @user-xu9zx9fd7n Před 3 lety

    if that problem of lsp with lua lsp you can use any vim package manager to download and install what you want even lsp

  • @davidstadelmann3278
    @davidstadelmann3278 Před 2 lety

    Cool tips. Netrw can be toggled by default with -

  • @markmcdonnell
    @markmcdonnell Před 2 lety

    I recommend the whichkey plugin

    • @benfrainuk
      @benfrainuk  Před 2 lety +1

      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?

    • @markmcdonnell
      @markmcdonnell Před 2 lety

      @@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. 🙂

  • @droid806
    @droid806 Před rokem +2

    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

    • @benfrainuk
      @benfrainuk  Před rokem

      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).

  • @user-xu9zx9fd7n
    @user-xu9zx9fd7n Před 3 lety

    Use null-ls and it will work with alot of language instead of formater

    • @benfrainuk
      @benfrainuk  Před 2 lety +1

      Thanks, swapped to null-ls now. Seems to keep the change list in tact now too

    • @user-xu9zx9fd7n
      @user-xu9zx9fd7n Před 2 lety

      @@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