Neovim - Power Tips: Volume 1

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024

Комментарии • 29

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

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

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

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

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

  • @محمدفرج-ث7ذ3د
    @محمدفرج-ث7ذ3د 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

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

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

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

  • @mvpopuk
    @mvpopuk 3 года назад

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

    • @benfrainuk
      @benfrainuk  3 года назад +1

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

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

  • @محمدفرج-ث7ذ3د
    @محمدفرج-ث7ذ3د 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

    • @محمدفرج-ث7ذ3د
      @محمدفرج-ث7ذ3د 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