Neovim

2535 readers
1 users here now

founded 2 years ago
MODERATORS
1
 
 

I simply want to emulate the effect of -p by default i.e. open all files in tabs when multiple files are supplied. I wrote the following autocommand to make it work.

-- Open files in tabs by default
vim.api.nvim_create_autocmd("VimEnter", {
    callback = function()
        if not vim.opt.diff:get() and #vim.fn.argv() > 1 then
            vim.cmd("tab sball")
            vim.cmd("tabfirst")
        end
    end,
})

But it seems to bork the colorscheme for all but the first tab. It's weird since Running the same commands manually after neovim is loaded works perfectly. I may have something to do with the order in which things are run. Is it possible to run this command as late as possible?

I'm open to alternative approaches that gets the job done.

2
 
 

While LLMs deliver at times questionable quality of code, they can be none the less helpful to give feedback, explain syntax or high level concepts. I was wondering how people are integrating them in neovim. How are you using LLMs? Is it worth thinking about a setup?

3
 
 

I use Obsidian for Zettelkasten note-taking. Anybody have a system in (Neo)Vim that they use?

4
 
 

nvim-dap 0.10.0 released

https://github.com/mfussenegger/nvim-dap/releases/tag/0.10.0

This is a smaller one. Mainly to drop support for nvim-0.9.5 on master.

I was hoping I'd get to wrap up the new breakpoint API and data and method breakpoint support, but that will have to wait for 0.11.0 or later.

@neovim
#neovim

5
6
12
submitted 5 months ago* (last edited 5 months ago) by mathias@social.fussenegger.pro to c/neovim@programming.dev
 
 

No-Config Python debugging using neovim

https://zignar.net/2025/03/02/no-config-python-debugging-using-neovim/

A follow up post of my earlier toot about no-config debugging that explains a bit more on how it works. (https://social.fussenegger.pro/@mathias/113970677458792689)

@neovim

#neovim

7
 
 

(Linked video showcases issue quite clearly)

I am using AstroNvim, but I believe that doesn't matter too much in this instance

I am very much new to html and js and the stuffs - but this tag indenting is catching me very offguard.
When I type a new tag it gets indented all nicely, and when opening a new line with o or O key, it nicely puts an indent if I am already in another tag. But when I then save with :w or ZZ, it reformats the indenting again... I think this might be two formatting agents fighting one another with different goals to format the xml tag indenting?

I installed node with npm, as it kinda seems that that is a requirement for working with html stuffs smoothly... and I installed some Lsp and ... stuffs with TsInstall and LspInstall and such... but I would expect those to not change formatting like this.

Has someone here experienced a similar issue? Is nvim in general maybe not the best for webdev? My friend uses brackets, which seems FOSS, but windows only >;(
Until recently, I mostly used nvim only for editing basic json and GDScript files, sometimes some cpp code even, and that worked great so far.

8
14
Lemmy neovim (lemmy.sdf.org)
submitted 5 months ago* (last edited 5 months ago) by you_are_it@lemmy.sdf.org to c/neovim@programming.dev
 
 

So how does this compare to reddit neovim?

Do you recommend some active opensource programming lemmys?

(edit. I'm new to lemmying)

9
 
 

Want to switch between projects fast or too lazy to cd into the project directory? Now you directly do that from neovim.

Details on installation in README.

10
 
 

Preview


What

So I really needed my pylsp to use a different pyenv install, and just want to share my basic solution in hopes it'll help someone else.

The basic gist of it is that I use vim.system() to get the version paths through pyenv:

pyenv root
pyenv versions --bare --skip-aliases

and create a telescope picker for selection.

Then I use vim.lsp.client.notify() with the workspace/didChangeConfiguration lsp method to change pylsp's settings (for which options can be found here).

Code

local pickers = require("telescope.pickers")
local finders = require("telescope.finders")
local conf = require("telescope.config").values
local actions = require("telescope.actions")
local action_state = require("telescope.actions.state")

local M = {}

M.get_pyenv_root = function()
    if not vim.fn.executable('pyenv') then
        vim.notify("pyenv executable not in path.", vim.log.levels.WARN)
        return nil
    end

    local root_cmd = vim.system({
        'pyenv',
        'root',
    }):wait()

    if root_cmd.code ~= 0 then
        vim.notify('"pyenv root" command returned non zero exit status.', vim.log.levels.WARN)
        return nil
    end

    local pyenv_root = string.gsub(root_cmd.stdout, '%s+', '')
    local pyenv_versions_path = vim.fs.joinpath(pyenv_root, '/versions')

    if not vim.fn.isdirectory(pyenv_versions_path) then
        vim.notify("Failed to find pyenv versions directory, '" .. pyenv_versions_path .. "'.", vim.log.levels.WARN)
        return nil
    end

    return pyenv_versions_path
end

M.get_pyenv_version_paths = function()
    if not vim.fn.executable('pyenv') then
        vim.notify("pyenv executable not in path.", vim.log.levels.WARN)
        return nil
    end

    local cmd = {
        'pyenv',
        'versions',
        '--bare',
        '--skip-aliases'
    }

    local versions_cmd = vim.system(cmd):wait()
    if versions_cmd.code ~= 0 then
        vim.notify('command "' .. vim.inspect(cmd) .. '" returned non zero exit status.', vim.log.levels.WARN)
        return nil
    end

    local versions = vim.fn.split(versions_cmd.stdout, '\n')
    return versions
end

M.get_pyenv_results = function()
    local pyenv_versions_root = M.get_pyenv_root()
    local results = {}

    if pyenv_versions_root == nil then
        return nil
    end

    local pyenv_versions = M.get_pyenv_version_paths()
    if pyenv_versions == nil then
        return nil
    end

    for _, version_path in ipairs(pyenv_versions) do
        table.insert(results, {
            version_path,
            vim.fs.joinpath(pyenv_versions_root, version_path),
        })
    end

    return results
end

M.set_pylsp_environment = function(python_env)
    local pylsp_clients = vim.lsp.get_clients({ name = "pylsp" })
    if pylsp_clients == nil or next(pylsp_clients) == nil then
        vim.notify("No Pylsp clients found.", vim.log.levels.WARN)
        return
    end

    local clients = 0
    for _, client in ipairs(pylsp_clients) do
        client.notify("workspace/didChangeConfiguration", {
            settings = {
                pylsp = {
                    plugins = {
                        jedi = {
                            environment = python_env
                        }
                    }
                }
            }
        })
        clients = clients + 1
    end
    vim.notify("Set python environment to '" .. python_env .. "' for " .. clients .. " pylsp clients.")
end

M.pyenvs = function(opts)
    opts = opts or {}
    local version_results = M.get_pyenv_results()
    if version_results == nil then
        return
    end

    pickers.new(opts, {
        prompt_title = "pyenvs",
        finder = finders.new_table({
            results = version_results,
            entry_maker = function(entry)
                return {
                    value = entry,
                    display = entry[1],
                    ordinal = entry[1],
                }
            end,
        }),
        attach_mappings = function(prompt_bufnr, _)
            actions.select_default:replace(function()
                actions.close(prompt_bufnr)
                local selection = action_state.get_selected_entry()
                M.set_pylsp_environment(selection.value[2])
            end)
            return true
        end,
        sorter = conf.generic_sorter(opts)
    }):find()
end

return M

And now you can easily open the picker with the M.pyenvs() function.

Also nice way to create the keymap for it is to wait for the LspAttach autocmd (which fires when an LSP is attached to a buffer) to fire and only create the keymap on the buffer that pylsp is attached to like so:

(don't forget to change the '<module_name>')

vim.api.nvim_create_autocmd("LspAttach", {
    callback = function(args)
        local client = vim.lsp.get_client_by_id(args.data.client_id)
        if client and client.name == "pylsp" then
            vim.keymap.set("n", "<leader>le", function()
                local pylsp_picker = require("<module_name>")
                pylsp_picker.pyenvs()
            end, {
                desc = "[e]nvironment (python)",
                buffer = args.buf
            })
        end
    end
})
11
 
 

I want to create a WYSIWYG editor for markdown, and I want it to be keyboard-driven with vim editing philosophy.

I want the editor to have rich formatting, rather than the equally spaced cells of characters in the terminal. This would enable rows having different text sizes, usage of non-monospaced fonts, editing RTL languages such as arabic or hebrew, and bypass other terminal limitations.

Embedding neovim would be nice in theory, enabling all compatible vim features. But it seems to come with great difficulties, since I am forgoing the entire rendering philosophy that neovim depends on (equally spaced cells of the terminal).

SO I am thinking it would be better to emulate the vim features I want, starting with basic keybindings and motions, and go from there. But I am worried that I might end up regret this choice? It seems that embedding neovim is too monumental of a task for what I want to do. Am I mistaken?

12
 
 

I like smooth scroll. I love Neovim. So I use Neovide. But I really wanted a nice way to manage instances per git repository / project, including server / remote socket management and allowing files to be opened into the correct instance. It detects running instances and opens into or switches to them accordingly.

This is also integrated into Finder and open via a swift wrapper. So one can, for example, use raycast to quick switch projects.

Check it out if that sounds interesting. There is also a longer video guide on the Usage wiki.

13
 
 

nvim-dap 0.9.0 released

See https://github.com/mfussenegger/nvim-dap/releases/tag/0.9.0 for the release notes.

@neovim #neovim

14
 
 

Released nluarepl 1.0.0

A Lua REPL for #neovim based on the debug adapter protocol.

See https://github.com/mfussenegger/nluarepl for more information and demos

@neovim

15
7
submitted 7 months ago* (last edited 7 months ago) by disrupted@lemmy.world to c/neovim@programming.dev
 
 

I need some advice how to handle project-specific plugin configuration for Neovim. My paid software gig involves work for several different client projects which are basically structured like this:

~/work-clientA
  - repoA1
  - repoA2
~/work-clientB
  - repoB1
  - repoB2
~/work-clientC
...

I manage the different environments using direnv.

What I struggle with is overriding/extending the config for Neovim plugins for each environment.

let's say for example clientA uses a self-hosted GitLab instance which requires me to override the lazy.nvim config for some Git-related plugins. How could I achieve this?

I looked into exrc. afaict this would require duplicating any client-specific configuration for each new repository. Instead what I would like is something like ~/work-clientA/init.lua which would then be sourced automatically for each project (repo) inside work-clientA.

16
 
 

Honestly... everybody should try out neovim for at least a week. I mean like... fully commit to it.

It's just amazing how fast and light on resource usage it is, compared to vscode.

For reference: I just opened qmk_firmware which has a shit load of clang code and files. Guess what, neovim doesn't even break a sweat, while vscode almost burns my CPU.

17
 
 

I'm generally skeptical of the hype around LLMs, but I've been manually working around this broken mapping for years. I don't think I could have found a solution easily just by googling.

18
 
 

🚀 Introducing Nevica: A modular, Vim-based IDE powered by Nix for maximum flexibility and reproducibility. 🔥

Nevica brings together the simplicity of Vim and the power of Nix, creating a fully customizable and reproducible development environment that works seamlessly across any OS that supports Nix—be it Linux, macOS, or even Windows.

Key Features:

•	Nix Integration: With Nix, your development environment is reproducible and consistent across different machines and operating systems.
•	Modular Design: Keep your setup lightweight by enabling only the languages and tools you need, with each language configured in its own module.
•	LSP Support: Full Language Server Protocol integration for autocompletion, real-time error checking, and code navigation.
•	Debugging & Diagnostics: Integrated tools for debugging and diagnosing issues across supported languages.
•	Customizable Flavours: Pre-configured profiles for various programming stacks, helping you set up quickly with the right tools for your workflow.
•	Code Formatting & Syntax Highlighting: Built-in support for consistent code formatting and syntax highlighting.

Why Choose Nevica?

Nevica is the ideal IDE for developers who need a lightweight yet powerful environment. Thanks to Nix, your setup is reproducible and works consistently on any operating system that supports Nix. Whether you’re on Linux, macOS, or Windows, you get the same reliable experience with Nevica.

💻 Try Nevica on GitHub: https://github.com/matteocavestri/nevica

I’d love to hear your feedback! Let’s improve Nevica together. 💬

19
20
6
submitted 10 months ago* (last edited 10 months ago) by IsoSpandy@lemm.ee to c/neovim@programming.dev
 
 

I was recently watching a tsoding stream when he was singing huge praises for the compilation mode in emacs, so I created a plug in to do essentially the same thing in neovim. Feel free to test it and share feedback.

error-jump

21
 
 

Hello, I’m a developer wanting to change from VSCode to Neovim. I’ve been using a Neovim extension for VSCode, so I know how to drive it to some extent.

I work with:

  • Rust
  • Typescript
  • React

I’m happy to use default NVim mostly with:

  • ctags
  • ins-completion
  • netrwtreelisting

I want to keep things really simple and use defaults when reasonable.

I basically just want to know how to set up Rust analyser and (for ts) prettier/eslint.

Questions:

  • Should I use a nvim conf file or lua? I’m happy to learn Lua if it’s recommended.
  • If I need packages for the above functionality, which package manager is best (excuse the imprecise terminology)?
  • Any additional recommendations?

Thank you.

22
23
 
 

I posted about this on Reddit a year ago, and I figured write about it again:

Like most companies, the one I work for will happilly pay for any employee's license to a proprietary IDE without batting an eye. Therefore, I argued that I should be able to spend that budget on a donation to an open source tool that I use daily instead. After a lot of back and forth I finally got them to donate an amount that would correspond to what they would pay for a yearly subscription to a proprietary tool to Neovim.

Do you use Neovim at work? If so, I urge you to do the same thing! That way the core team can continue to deliver awesome new features to the editor we all love. Here's a link to where you can donate.

I now got my work to pay a $400 yearly "Neovim subscription" for the second time.

To those wondering how I did it, I basically just argued that since employees at my work have an allocated budget for buying proprietary tools, it makes sense if we could spend an equivalent amount on a FOSS alternative. That way the money spent would benefit us all, and since we use the tool to make money we have a responsibility to give back to the FOSS project.

There was a bit of a back-and forth for technical reasons because (at least in Sweden where I live), payments and donations are handled and regulated differently, but they finally made it work.

If you also use Neovim for work, I encourage you to do the same thing! That way the core team can continue to deliver awesome new features to the editor we all love. Here's a link to where you can donate. There's also the official merch store if you would like to support the project that way: https://store.neovim.io/.

24
 
 

I start my coding workspaces in tmux sessions which persist when I log out. If I switch from a wayland session to an x11 session, then my copy and paste functionality in those neovim sessions are broken because it's still trying to use wl-copy. To be more precise:

  1. Start a wayland session.
  2. Open a terminal and start a tmux session.
  3. Open neovim and do some work.
  4. Log out of wayland, log into an X11 environment
  5. Open a terminal and reconnect to the tmux session
  6. "+y broken. clipboard: error invoking wl-copy: Failed to connect to a Wayland server...

Restarting neovim isn't sufficient. I have to restart the entire tmux session or switch back to wayland. Is there some short cut I can take here?

25
 
 

Hi! I've created refjump.nvim which is a plugin that lets you use ]r/[r to jump to the next/previous LSP reference in the current buffer for the item under the cursor.

The plugin also automatically integrates with demicolon.nvim if you have it installed, which I recently posted about. This means that you can also repeat the jumps forward/backward with ;/,.

Here's a video showing it in action.

Enjoy!

view more: next ›