Neovim

2068 readers
1 users here now

founded 1 year ago
MODERATORS
51
52
 
 

Really enjoying nvim-dap-ui lately, but I always have to adjust the sizes of the windows. The docs have left me high and dry so far, but maybe one of you have a good solution for a consistent layout when you first attach to a file?

53
 
 

Looking for a way to migrate from Arduino IDE to get everything in NeoVim, but I get lost in the weeds without a working example or reference. I'm wondering if this is actually practical and more than a novelty for anyone here.

54
55
11
Help with snippets? (lemmy.sdf.org)
submitted 5 months ago* (last edited 5 months ago) by [email protected] to c/[email protected]
 
 

My goal is to automatically close the environment while editing a tex file. There was an issue for vimtex asking for basically what I want to achieve. They achieve it using snippets as mentioned there.

The problem is, I have no idea how to set it up. I've never used snippets in nvim. I have vim-vsnip and cmp-vsnip installed as it was needed for another plugin to work. Is it possible to implement this using those?

It can be noted that in vimtex, an environment can be closed by typing ]] which is a mapping of vimtex-delim-close. I basically want to emulate the behavior in VS Code using LaTeX Workshop. It auto-closes the environment, adds an indented line in the middle, and moves the cursor there.

If anyone has any other ideas about doing this without snippets, that's welcome too.

56
 
 

Hi I've been looking at nyoom.nvim and it alters the UI of telescope (see screenshot) I was just wondering how this is possible? I looked d through the codebase but couldn't find anything other than the setting of colours?

Here is the repo: https://github.com/nyoom-engineering/nyoom.nvim

57
 
 

cross-posted from: https://discuss.online/post/5797974

TJ has a walkthrough of installing NeoVim and his Kickstart.nvim package for people new to NeoVim. He explains what is going on so you can then further customize your NeoVim setup.

I used NeoVim with Kickstart.nvim to get my NeoVim setup initialized. It's great.

58
11
submitted 5 months ago* (last edited 5 months ago) by [email protected] to c/[email protected]
 
 

I'd like a treesitter query that matches a Rust struct together with all of its attributes. For example,

#[derive(Debug)]
#[serde(rename_all = "camel_case")]
pub struct MyType {
    pub foo: i32,
}

The lines beginning with # are attributes that are logically connected to the struct declaration. But the treesitter grammar for Rust parses attributes as adjacent nodes, not as children of the struct declaration:

  (attribute_item ; [27, 0] - [27, 16]
    (attribute ; [27, 2] - [27, 15]
      (identifier) ; [27, 2] - [27, 8]
      arguments: (token_tree ; [27, 8] - [27, 15]
        (identifier)))) ; [27, 9] - [27, 14]
  (attribute_item ; [28, 0] - [28, 35]
    (attribute ; [28, 2] - [28, 34]
      (identifier) ; [28, 2] - [28, 7]
      arguments: (token_tree ; [28, 7] - [28, 34]
        (identifier) ; [28, 8] - [28, 18]
        (string_literal)))) ; [28, 21] - [28, 33]
  (struct_item ; [29, 0] - [31, 1]
    (visibility_modifier) ; [29, 0] - [29, 3]
    name: (type_identifier) ; [29, 11] - [29, 17]
    body: (field_declaration_list ; [29, 18] - [31, 1]
      (field_declaration ; [30, 4] - [30, 16]
        (visibility_modifier) ; [30, 4] - [30, 7]
        name: (field_identifier) ; [30, 8] - [30, 11]
        type: (primitive_type)))) ; [30, 13] - [30, 16]

How can I get produce a query that I can use in mini.ai that matches the struct, and all attributes?

I've tried this query using Neovim's new built-in :EditQuery command:

((attribute_item)* . (struct_item)) @custom_capture.outer

It looks like it does what I want. But when I try using @custom_capture.outer in mini.ai it matches the struct declaration, but not the attributes.

I tried using #make-range! like this,

((attribute_item)* @_start . (struct_item) @_end
  (#make-range! "custom_capture.outer" @_start @_end))

That matches the struct and the second attribute, but does not get the first attribute. I'm guessing that's because the . specifies that nodes must be adjacent, and the second attribute is the only one that is adjacent to a struct_item. Following that thinking I tried this,

((attribute_item)? @_start . (attribute_item)* . (struct_item) @_end
  (#make-range! "custom_capture.outer" @_start @_end))

That gets the struct and all the attributes, but only if my cursor is on the first attribute line when I use the textobject. If my cursor is on any subsequent line then I get the second attribute and the struct, but the first attribute is missed.

One problem is I'm not clear whether ((attribute_item) . (struct_item)) matches an attribute_item and a struct_item that are adjacent, or matches an attribute_item that precedes a struct_item, but does not also match the struct_item. I tried experimenting with the second interpretation and used this query,

(((attribute_item) 
  . [(attribute_item) (struct_item)])* @_start
  (struct_item) @_end
  (#make-range! "custom_capture.outer" @_start @_end))

That captures what I want, but in some cases if I have two struct declarations and I try to match only the second one the query selects both structs instead.

Is that the way to do a lookahead? Or is there another way?

I've kinda hit a wall looking at documentation, other examples, and running my own experiments. Does anyone have any pointers to help understand these queries on a deeper level?

Edit: It looks like this stuff is in flux, so I should mention that I'm using the latest nightly as of March 2 2024, and I made sure that all of my plugins are up-to-date.

59
10
submitted 6 months ago* (last edited 6 months ago) by [email protected] to c/[email protected]
 
 

Fairly new neovim user here, so bear with me if I don't get everything.

I'm using neovim with Telescope and I often struggle with the following process: I want to be able to easily save my past yanks and deletions and fuzzily find the one that interest me now. Is there a way to configure Telescope to look into registers for that ?

Also, is there a way to keep the history of deletion as well ? Sometimes I'm deleting A, deleting B, deleting C and want to past A which is no longer accessible (unless I remember to put it in a named register in the first place, which I rarely do).

60
 
 

Hello all, as someone who mainly prefers dark themes but also enjoys black text, I created this semi-light neovim color scheme. https://gitlab.com/sxwpb/halfspace.nvim

The goal was having a theme that uses black text but avoids the eye melting of most light themes. In fact the background color is #808080, which is the midpoint of a monitors brightness. Using such a background comes at a hefty cost of text contrast, thus all chosen syntax colors are kept pretty close to the best possible contrast here which is black text.

Let me know what you think and I know lots of people absolutely despise this type of color combination which I understand, so please be kind in that case.

happy vimming

61
62
63
 
 

kitty-scrollback.nvim v4.0.0 is officially released! Check out the announcement here.

What is kitty-scrollback.nvim?

A Neovim plugin (and Kitty Kitten) that allows you to navigate your Kitty scrollback buffer to quickly search, copy, and execute commands in Neovim.

kitty_scrollback_screencapture_00_kitty_scrollback_nvim

Check out Advanced Configuration Examples for more demos!

What changed?

See Migrating to v4.0.0 for the detailed migration guide.

  • Previously, kitty-scrollback.nvim did not open Neovim with your Neovim configuration by default. This has changed to loading your Neovim configuration by default, with the ability to opt out. If you prefer to continue not loading your Neovim configuration, then follow the steps at No Configuration.
  • If you previously used the flag --no-nvim-args, then delete it from your configuration because it no longer has any effect. The flag --nvim-args remains unchanged and can still be used.
  • ksb_example configurations have been removed and can no longer be referenced by name. If you were previously referencing an example configuration by name, then you can manually copy it from ./tests/example.lua into your kitty-scrollback.nvim configuration. See Plugin Configuration for detailed instructions on configuration kitty-scrollback.nvim.
  • The command KittyScrollbackGenerateKittens and api generate_kittens no longer have an option to generate ksb_example configurations.
    • The command KittyScrollbackGenerateKittens no longer accepts the bang ! modifier
    • The api generate_kittens signature removed the all parameter
  • The reserved global configuration name has been removed and global options are now configured by the first element of the options table without a key. See Global Configuration for more details.
  • The undocumented reserved default configuration name has been removed. kitty-scrollback.nvim defaults to ksb_builtin_get_text_all if no configuration is provided.

Other minor version updates

  • You can now paste and execute commands directly from visual mode! Previously, this could only be done with the paste window that is used for editing commands. Check out the demos in the Features section.

kitty_scrollback_screencapture_03_should_paste_visual_selection_to_kitty

  • The environment variable KITTY_SCROLLBACK_NVIM was added and is set to true while kitty-scrollback.nvim is active. See Environment Variables.
  • Documented the filetype kitty-scrollback and provided an example of using it in an autocmd. See Filetypes.

What's next?

The next feature I plan to work on is adding tmux support (see #155).

If you have any questions, comments, or feedback feel free to create an issue or open a discussion.

64
65
66
67
68
 
 

Hi! I recently decided to switch from airline, but can't find a status / tab line plugin that works just like I want it to. Lualine is the closest I could get, but the following features from tabline is really missing from me.

I couldn't get the buffer component to only show those buffers that are open on the current tab, and in the visual order that my splits are. Also I can't get it to hide hidden buffers, after opening and closing a few terminals it gets polluted with a tons of unnecessary tabs

The closest I could get is with "tiagovla/scope.nvim", but that does not make it respect the order of my splits, messes with sessions and doesn't solve the problem with the hidden buffers

Is there a tabline extension that is simple and fast, and can do what I described? Thanks in advance

69
 
 

Hi

As the title suggests, I want to set something up so that while trouble is_open(), I have a keyboard shortcut that cycles through the various modes listed at https://github.com/folke/trouble.nvim/tree/main#commands.

I see how I can assign shortcuts to jump directly to the different modes, but I want to remember only one shortcut.

Writing a bit of lua to do this is easy enough, but I can't find any way to see what mode it's currently in, in order to write some function that toggles to the next one.

Is there any way to accomplish this?

Bonus question: Is there any way to get trouble to display on screen what mode it's currently in? Such as at the top or bottom of the trouble panel.

70
 
 

I am looking for a neovim colorscheme that is customizable and is best in terms of offered features. What features? well, at least granularity in highlight groups, performance (preferably using tree-sitter), customizability and documentation. If you know of any other fancy features, I will take those too.

I have tried

71
 
 

Hey all, if you use it looks like rust-tools.nvim has been archived.

They recommend rustaceanvim which has a migration guide here.

72
 
 

Posting just because I looked all over and didn't see an answer. This function expands its arguments to canonical, absolute file paths, and tests whether one is a string prefix of the other. It also works for checking whether a directory is inside of or is identical to another directory.

local is_file_in_directory = function(file_path, directory_path)
  local file = vim.fn.fnamemodify(file_path, ':p')
  local dir = vim.fn.fnamemodify(directory_path, ':p')
  return file ~= nil and dir ~= nil and
      -- is dir an initial substring of file?
      file:find(dir, 1, true) == 1
end

This came up because I'm setting up obsidian.nvim which looks like a handy way to get the best of both worlds between Obsidian and Neovim. I'm setting up some custom configuration to automatically change the selected Obsidian workspace when I cd into vault directory, and to set conceallevel = 1 only on files in a vault, and that requires checking whether the working directory or a file path is inside a given vault directory.

73
 
 

After about 20 years of Eclipse IDE I have decided to gradually switch to Visual Studio Code. Planing to adopt new keybindings as well. As an alternative, I have started playing with @neovim. Stack Overflow developer survey 2023 (I'm surprised by notepad++ popularity, though I use it too):

74
 
 

As title.. Thanks

75
 
 

So I just had an issue where my shebang lines weren't parsing properly for a python script I was attempting to execute. A quick google revealed that it was probably because I wrote the scripts on windows and now I was trying to run them on Linux (so happy i finally made the switch btw. using the computer is fun again!). So i took the advice I found and tried to run :%s/^M/ (using C-v, C-m to insert the escape character), and it failed to find any matches. I tried the same command in vanilla vi and it worked.

Is there some setting I don't have configured properly? I would prefer to be able to do this sort of thing within neovim.

view more: ‹ prev next ›