Neovim - Power Tips: Volume 1

Поділитися
Вставка
  • Опубліковано 12 вер 2024

КОМЕНТАРІ • 29

  • @rsmith31416
    @rsmith31416 2 роки тому +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.

  • @stephenbrown-bourne465
    @stephenbrown-bourne465 2 роки тому +1

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

  • @_jdfx
    @_jdfx Рік тому +1

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

    • @benfrainuk
      @benfrainuk  Рік тому +1

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

  • @narwashius1176
    @narwashius1176 2 роки тому

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

    • @benfrainuk
      @benfrainuk  2 роки тому +1

      Thanks Narwash 👍 definitely more on the way!

  • @JanChristophEbersbach
    @JanChristophEbersbach 2 роки тому

    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  2 роки тому +1

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

  • @diarmaidmac2149
    @diarmaidmac2149 3 роки тому

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

    • @benfrainuk
      @benfrainuk  3 роки тому

      Thanks Diarmaid! Appreciate it 👍

  • @willadams6217
    @willadams6217 3 роки тому

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

    • @benfrainuk
      @benfrainuk  3 роки тому

      Excellent Will. Thanks. Will do!

  • @kimnielsen7818
    @kimnielsen7818 Рік тому +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 2 роки тому +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 2 роки тому

      why did half my comment disappear?

    • @Brazen_Braden
      @Brazen_Braden 2 роки тому

      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  2 роки тому +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

  • @user-xu9zx9fd7n
    @user-xu9zx9fd7n 3 роки тому

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

  • @mvpopuk
    @mvpopuk 2 роки тому

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

    • @benfrainuk
      @benfrainuk  2 роки тому +1

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

  • @davidstadelmann3278
    @davidstadelmann3278 2 роки тому

    Cool tips. Netrw can be toggled by default with -

  • @markmcdonnell
    @markmcdonnell 2 роки тому

    I recommend the whichkey plugin

    • @benfrainuk
      @benfrainuk  2 роки тому +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 2 роки тому

      @@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 Рік тому +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  Рік тому

      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 3 роки тому

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

    • @benfrainuk
      @benfrainuk  2 роки тому +1

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

    • @user-xu9zx9fd7n
      @user-xu9zx9fd7n 2 роки тому

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