Neovim

2068 readers
1 users here now

founded 1 year ago
MODERATORS
1
 
 

When using LuaSnip together with nvim-cmp and a snippet library like friendly-snippets or luasnip-snippets you get a lot of duplicated snippets. That's because the language server also servers snippets. Also, you might want to create your own custom snippet that happens to share the name of a snippet that already exists.

For example, with the setup mention above, let's say that I also have a custom fn snippet for Rust files. When I type fn, nvim-cmp suggests three snippets: one from rust-analyzer, one from friendly-snippets and my custom one.

The solution to overriding friendly-snippets with your custom ones suggested in this open LuaSnip issue is to create your own fork of friendly-snippets. However, this is not ideal because it adds a lot of extra work to each user to ensure that their fork is up-to-date with upstream. Also, it doesn't solve the issue with language servers serving snippets with the same name. I know that for most language servers you can disable snippets, but that doesn't really solve the issue either because you might want some of those snippets.

What I would like is the option to only see one of the snippets listed if there are multiple ones with the same name. Which one would be controlled with a priority list, for example:

  1. If there's a custom user snippet, use that
  2. Otherwise, if there's an LSP snippet, use that
  3. Otherwise, use the one from friendly-snippets

Is this possible to achieve today?

2
21
submitted 5 days ago* (last edited 1 day ago) by [email protected] to c/[email protected]
 
 

Hello, I wanted to share a small keymap I made. It lets you inspect unsaved changes in the current file. It uses diff mode, in a vertical split.

To close the diff mode, just press q in the scratch buffer.

vim.keymap.set(
	'n',
	'<M-C-D>',
	function()
		local tmpft = vim.bo.filetype
		vim.cmd.vnew()
		vim.bo.filetype = tmpft
		vim.bo.buftype = 'nofile'
		vim.keymap.set(
			'n',
			'q',
			'<cmd>bw<cr>',
			{ noremap = true, silent = true, buffer = true }
		)
		vim.cmd('silent r#|0d_')
		vim.bo.modifiable = false
		vim.cmd('diffthis|wincmd p|diffthis')
	end,
	{ noremap = true }
)

edit: I discovered that this functionality is actually documented in the help pages (:h :DiffOrig). It’s basically the same action but bound to a command

3
 
 

Hi everyone! I've created a new Neovim plugin: demicolon.nvim. It lets you use ; and , keys to not only repeat t/T/f/F motions, but also to repeat diagnostic motions like ]w (jump to next warning) as well as jumps to nvim-treesitter-textobjects like ]f (jump to next function).

Video previewing it in action.

That's all. Have a great day!

4
 
 

What issues or frustrations have you encountered in trying to use and set up Neovim in Windows 11?

I'm currently writing up my experience with installing, setting up, and using Neovim in Windows and would like to hear from others that have tried the same. What was annoying, difficult, or impossible in your experience?

5
 
 

Is there some intuitive menu mode that is simple to initiate? The packaged setup with dnf on F40 only has the colon help menu enabled. I don't care about mouse Luddites or the remarkableness of people with total recall. I need something like gedit level tools to just work without Planck scale resolution help, or learning career to make a useful hobby tool that is free from stalkerware nonsense like an electron based IDE.

6
7
 
 

Based on answers to the following question:

Which development environments did you use regularly over the past year, and which do you want to work with over the next year? Please check all that apply.

Neovim is the most admired code editor in the 2024 Stacked Overflow Developer Survey

Source: https://survey.stackoverflow.co/2024/technology#admired-and-desired-new-collab-tools-desire-admire

8
 
 

It's broader than a Neovim specific mapping, I've changed the system keyboard mapping of <Caps Lock> to <Esc> and <F9> to <Caps Lock>.

I think mapping <Caps Lock> to <Esc> isn't uncommon for Neovim users. But I like having <Caps Lock> available for non Neovim purposes.

9
10
 
 

Difftastic is a diff tool that uses treesitter parsing to compare code AST nodes instead of comparing lines. After following the instructions for use with git I'm seeing some very nice diffs when I run git diff or run git show --ext-diff. I thought it would be nice to get the same output for hunk diffs in the fugitive status window, and in fugitive buffers in general (which use the git filetype). But I haven't seen any easy way to do it. Has anyone got a setup like this?

I can run a command in neovim like :Git show --ext-diff to get difftastic output in a buffer. I'm thinking maybe I can set up fugitive to use the --ext-diff flag by default, or set up some aliases. But there is no syntax highlighting for the difftastic outputs since the ANSI color codes that difftastic uses in interactive terminal output don't work in neovim, and the syntax highlighting for the git filetype assumes standard diff output which is not compatible with difftastic output. For me losing colors is not a worthwhile trade for the otherwise more readable diff output.

My best idea right now is to set up a new filetype called difftastic, and write a new treesitter grammar or syntax plugin for it. Then set up some kind of neovim configuration to feed output from difftastic into buffers with the new filetype.

There is an open neovim issue discussing adding syntax-aware diffs directly to neovim, but that doesn't seem to have gone anywhere.

11
 
 

setting it up like this implements the nvim-web-devicons API, so many plugins that depend on that work with mini.icons too!

	require('mini.icons').setup()
	MiniIcons.mock_nvim_web_devicons()
12
 
 

Not mine but this is a great plugin for customising the native LSP inlay hints. Hope some of you also find it helpful.

This is related to an earlier post I made, asking if there was a way to move the native LSP hints to the end of a line rather than appearing within the line. Found exactly what I was looking for with this plugin!

13
56
submitted 1 month ago* (last edited 1 month ago) by [email protected] to c/[email protected]
14
 
 

My new design direction for neovim is "you just sat down in a homie's spaceship and have no idea what any of the buttons do" -- you can see how I did it here with tabby.nvim: https://github.com/Garoth/Configs/blob/da354cd98241dc7582718a9082226fab99403e4a/nvim/init.vim#L752

I'm an oldschool vim guy, so a lot of my plugin tastes lean towards the ancient. Telescope?? Nah I had that figured out with fzf.vim many years ago, and it's stupid fast. Harpoon? Nah, I have marks, permanent undo and location memory, alternate files, fast search. Plus I love using fzf in my terminal so it all blends together so well. I still use vim-plug, it's pretty much perfect, and have no interest in lazy or whatever the new flavor-of-the-year package manager is

Neovide continues to be what I believe is the future of neovim. The performance is best in class, probably theoretically better than even terminals can achieve (since rendering can be done much more selectively, understanding vim concepts like floating windows and such, which have compositing in neovide). The idea of "progressive improvements" in a GUI rather than trying to make something totally different is a great call. In the future, they are likely to implement a new age of image rendering too, which would be aware of z-index layering (so you could have a floating window on top of an image -- current image-in-terminal approaches just put the image on top)

Airline -- well, this is in the category of "if it aint broke dont fix" -- Airline has been in development for like 11 years and has 2700+ commits, 17k+ stars on github. I mean, this is a ridiculous history, that's more work than most projects on github, just for a statusline. I don't tend to chase trends or replace vim code with lua - who cares - vimscript is stable and reliable

Shoutout to the Maple Mono font -- with a lot of amazing ligatures that I didn't have before, super cozy. Demo recorded on an 7 year old samsung chromebook running Wayland/Pipewire Arch with a dualcore cpu, 4gb of ram, 14nm intel integrated graphics, and a 32gb harddrive. Linux is so cool, being able to do that. The ending was... not on purpose lmao

15
9
submitted 1 month ago* (last edited 1 month ago) by [email protected] to c/[email protected]
 
 

idk im having this issue for a long time. itd be nice to have this fixed.

thanks

Edit: I that doesnt help:

  • term=xterm-... in shell config
  • set-option -ga terminal-overrides ",xterm-256color:Tc" in tmux config

solution:

thanks to mazadin for the solution.

im using foo terminal, so setting set-option -ga terminal-overrides ",foot:Tc" in tmux.config fixed it. (yeah im dumb)

16
17
 
 

Been using LunarVim which seems discontinued and started to break recently. Probably moving to SpaceVim soon. Other distro's being used here?

18
 
 

I made a small plugin that other people might find handy. It checks if the file open in the current buffer has write access and if not, prompts for sudo (or any other command at your choice) and copies the file.

No longer do you need to care about forgetting to use sudoedit or anything else, just edit the files you want to edit! This could change the world!!1!

But in all seriousness, this is my first neovim plugin and I barely spent an hour on it but it's simple and it gets the job done. It scratches a minor itch and maybe you'll also find it useful.

19
 
 

This is parrot.nvim, the ultimate stochastic parrot to support your text editing inside Neovim.

Frank Röder started this repository because a perplexity subscription provides $5 of API credits every month for free. Instead of letting them go to waste, he modified his favorite GPT plugin, gp.nvim, to meet his needs - a new Neovim plugin was born! 🔥

Unlike gp.nvim, parrot.nvim prioritizes a seamless out-of-the-box experience by simplifying functionality and focusing solely on text generation, excluding the integration of DALLE and Whisper.

Features

  • Persistent conversations as markdown files stored within the Neovim standard path or a user-defined location
  • Custom hooks for inline text editing with predefined prompts
  • Support for multiple providers:
  • Custom agent definitions to determine specific prompt and API parameter combinations, similar to GPTs
  • Flexible support for providing API credentials from various sources, such as environment variables, bash commands, and your favorite password manager CLI
20
 
 

I'm normally a straight vim user (just out of habit, no particular preference) and I'm giving neovim a spin. So far I like it but...

For the love of all that's holy, how do I disable automatic indentation?

I have noautoindent set, nosmartindent set, filetype indent off, but neovim keeps inserting indentations. The only thing that works is setting paste on, but that's not the right solution to this problem.

Please help. This is driving me nuts!

21
22
 
 

I'm on NixOS and slowly working through neovim config.

I have treesitter installed with all grammars and it's set up in lua. When I run :TSymbols, it pops open a window showing -----treesitter-----, but no symbols are shown from the (python) code I have open.

All of the setup is put in place by the config flake I'm using, but I don't think there's any additional stuff to add for symbols to work. The treesitter section in the resulting init.lua from nix looks like this:

require('nvim-treesitter.configs').setup({
      ["context_commentstring"] = { ["enable"] = false },
      ["highlight"] = { ["enable"] = true },
      ["incremental_selection"] = {
        ["enable"] = false,
        ["keymaps"] = {
          ["init_selection"] = "gnn",
          ["node_decremental"] = "grm",
          ["node_incremental"] = "grn",
          ["scope_incremental"] = "grc"
        }
      },
      ["indent"] = { ["enable"] = false },
      ["refactor"] = {
        ["highlight_current_scope"] = { ["enable"] = false },
        ["highlight_definitions"] = {
          ["clear_on_cursor_move"] = true,
          ["enable"] = false
        },
        ["navigation"] = {
          ["enable"] = false,
          ["keymaps"] = {
            ["goto_definition"] = "gnd",
            ["goto_next_usage"] = "<a-*>",
            ["goto_previous_usage"] = "<a-#>",
            ["list_definitions"] = "gnD",
            ["list_definitions_toc"] = "gO"
          }
        },
        ["smart_rename"] = {
          ["enable"] = false,
          ["keymaps"] = { ["smart_rename"] = "grr" }
        }
      }
    })
23
24
25
view more: next ›