Neovim

1819 readers
1 users here now

Neovim is a modal text editor forked off of Vim in 2014. Being modal means that you do not simply type text on screen, but the behavior and functionality of the editor changes entirely depending on the mode.

The most common and most used mode, the "normal mode" for Neovim is to essentially turn your keyboard in to hotkeys with which you can navigate and manipulate text. Several modes exist, but two other most common ones are "insert mode" where you type in text directly as if it was a traditional text editor, and "visual mode" where you select text.

Neovim seeks to enable further community participation in its development and to make drastic changes without turning it in to something that is "not Vim". Neovim also seeks to enable embedding the editor within GUI applications.

The Neovim logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.

founded 4 years ago
MODERATORS
51
 
 

Hi, I’m new to neovim so there’s a decent chance this is just a rookie mistake. I wanted to make an autocmd to remap F5 to running the (python) file. I found a stack overflow post on how to do this (https://stackoverflow.com/questions/18948491/running-python-code-in-vim ) but that was for vim. I tried my best to translate if for neovim using some other tutorials I found (and doing my best at understanding docs), what I came up with is this:

local api = vim.api
local RunFile = api.nvim_create_augroup("RunFile", { clear = true })

api.nvim_create_autocmd(
    "FileType",
    {
        callback = "map <buffer> <F5> :w<cr>:exec '!python3' shellescape(@%, 1)<cr>",
        pattern = "python",
        group = RunFile,
    }
)

however when I include the file in my init.lua, not only does it not work (the autocmd doesn’t even show up when looking in :au FileType, let alone run) it also makes the text a boring white and when I try to format, it gives the error [LSP] Format request failed, no matching language servers. while I definitely do have the language server (it works when the autocmd file is not included in init.lua). I’m probably just making some simple mistakes, but I cannot for the life of me find what I’m doing wrong. Does anyone here have any suggestions? For the record, I use lsp zero and treesitter

52
53
 
 

Zeioth has created a fantastic plugin for those of you looking to make Neovim more like an IDE. Run the open command, tell it to build, have it compile, execute, and output your code in a really nice looking way all inside neovim.

It's still pretty early but this is looking promising. It's already very customizable with support for a few languages, with more in the works.

Give it a look: https://github.com/Zeioth/Compiler.nvim

54
 
 

I've been absolutely loving treesitter. It's come a long way and it's been absolutely great for things like folds, motions, highlights of course. Now that I've finally gotten familiar with writing my own queries I can extend the existing plugins. As an example I've added folds to blocks of multiple consecutive comments in JS and Ruby.

What are some of your favorites?

55
4
submitted 2 years ago* (last edited 2 years ago) by lung@lemmy.world to c/neovim@sopuli.xyz
 
 

Hey guys, I'm currently one of the active members the neovim reddit (hugelung), and I'm in full support of migrating to lemmy. I was hoping to be modded here, and helping migrate content / roll people over

56
5
Weekly dotfile review? (sh.itjust.works)
submitted 2 years ago* (last edited 2 years ago) by em_s_h@sh.itjust.works to c/neovim@sopuli.xyz
 
 

What does everyone think about doing a weekly dotfile review thread like r/neovim does.

I personally really like to see different neovim configurations that other people have made.

Edit: my config

Edit 2: I also think that if we are to do these, they should be done on the weekends, since that is the time when people aren't busy with their jobs or school.

57
 
 

Am I the only one who struggle with cmp comparators? I can't make any setup to work like I want it to work.

Like come on, diagramIds is literally on the line above ...

The comparators aren't even documented: https://github.com/hrsh7th/nvim-cmp/issues/883

This is the closest thing I could find to usefull: https://github.com/hrsh7th/nvim-cmp/issues/183 but it didn't help either

How did you manage to cope with this? Is there some reasonable setup for cmp comparators?

58
 
 

Hey all, just a heads up that https://github.com/neovim/neovim/discussions has been reopened in the light of the r***it situation.

59
 
 

Just wondering: how would you characterize the general feel of the different nvim flavours: LazyVim, Chad, Astro, etc.? I'm not thinking functionality, which plugins are included, etc., but the way they feel when one uses them.

I tried out a whole bunch of them, as per Elijah Manor's excellent video about config switching (https://www.youtube.com/watch?v=LkHjJlSgKZY)

I figured out LazyVim is trying its best not to look and feel like vim, with modal windows and fancy graphics and all. I didn't like that. I can't remember why I left Astro behind, but I finally settled on Chad, which at first I disliked because of the name, but eventually I figured out that that was the flavour for me: so many things just worked as expected, and there were so many times when I looked up something, and went: "Hm! That was quite smart, actually!"

So that's where I'm at – and purely for "feel" reasons. So: convince me: what am I missing when I don't use bundle B or config C?

60
 
 

Hey all. I recently made the jump to using neovim as my full-time editor of choice using a modified version of LazyVim. I'm looking for a plugin that shows Markdown preview (preferably within a buffer and not by opening a browser page, if that's possible). This is primarily for taking notes at work, although I don't need the most heavyweight note taking app (for that I usually use Notion, which unfortunately doesn't seem to have a read-write neovim plugin). Do you have any recommendations?

61
 
 

e.g. the builtin live_grep function. Particularly if it has to open a buffer, the cursor is just on line 1, not the line I selected in Telescope. I think it might be to do with folding?

Just wondering if anyone else had this and knew a fix?

62
 
 

The r***it neovim community is fab and taking part in the go-dark outage protest. I think open source communities are better served by open not for profit, decentralized community-apps like this. The corporaate ones always go bad in the end. Reddit and Github both allowed their data to feed the big tech power grab that is LLMs.

63
 
 

So, instead of running to reddit, i'll give this a shot here. I'm in the process of making my own NeoVim Configuration from scratch. One of the tools i use is sidebar-nvim . This allows me to make my own Sections. I'm pretty new to lua and have never dabbled in plugin programming before. Through reading the source of sidebar-nvim and neovim-session-manager I have gotten to a point where i get a list of my sessions in the sidebar.

local session_manager = require("session_manager.utils")
local sessions = session_manager.get_sessions()
local dirs = {}
local filenames = {}

for _, file, _ in pairs(sessions) do
  local directory = session_manager.shorten_path(file.dir)
  table.insert(dirs, directory)
  table.insert(filenames, file.filename)
end

local section = {
  title = "Sessions",
  icon = " ",
  draw = function()
    return dirs
  end,
  bindings = {
    ["l"] = function(line, col)
      local filename = filenames[line]
      session_manager.load_session(filename, false)

    end,
  }
}

return {
  "sidebar-nvim/sidebar.nvim",
  config = function()
    require("sidebar-nvim").setup({
      open = true,
      side = "right",
      sections = {
        "datetime",
        "symbols",
        section,
        "git",
        "todos",
        "diagnostics"
      },
    })
  end
}

The thing that isn't working is the "bindings". session_manager.load_session takes the filename out of the original sessions table. I have no clue how the original structure looks. My attempt currently returns an empty value. Anyone have an idea how to access the data i need to get the session loaded properly?

64
2
time tracking (lemmy.world)
submitted 2 years ago* (last edited 2 years ago) by atomdmac@lemmy.world to c/neovim@sopuli.xyz
 
 

I've been using Wakatime recently and while I like the functionality quite a bit I don't really want to pay $15 per month to use it. It seems a little steep to me so I'm looking for free and open source alternatives. Does anyone here have one that they like?

Edit: I started messing with https://timetagger.app and writing a quick adapter to start/stop the clock from neovim. I've beentestingg it out over the last few days and so far, I really like it

65
7
This Week In Neovim Newsletter (this-week-in-neovim.org)
submitted 2 years ago* (last edited 2 years ago) by ds12@beehaw.org to c/neovim@sopuli.xyz
 
 

Just wanted to share a newsletter that a Neovim community member has been putting out weekly. Content is categorised under Core and Plugin (hopefully self-explanatory). I usually find interesting things to learn about Neovim's core and API, or plugins to explore!

66
67
 
 

I've managed to put this together couple days back and thought I'd share, I expect I'm not the only person out there who likes neovim and switching light/dark modes. Cheers!

68
69
70
71
 
 

For any questions related to configuring Neovim with Lua or migrating over to Lua from Vimscript.

72
 
 

this is my config on moonscript

share your configs on lua, vimscript or on other languages in comments :^)

73
 
 

I gave it a go last night and it is way trickier then I expected. Simple things like setting options are not very convenient at the moment. I also tried to get packer.nvim running but the README was not very helpful.

Looks like I will be sticking with init.vim for some time.