#+TITLE: Neovim installation on WSL2 Debian Windows 11 #+SUBTITLE: #+DESCRIPTION: #+AUTHOR: Tuomas Pyyhtiä #+EMAIL: #+DATE: #+KEYWORDS: # Export underscore as underscore instead of highlight in HTML: #+OPTIONS: ^:nil # Include usable macros from https://github.com/fniessen/org-macros: #+INCLUDE: ../org-mode/macros/org-macros.setup #+INFOJS_OPT: view:showall ltoc:nil path:https://iki.fi/~pyyhttu/debian/org-mode/js/org-info.js #+HTML_HEAD: * Neovim ** Philosophy I've been using Vim since ~2008, but Neovim has meanwhile gathered a very vibrant plugin community for writing and notes, which is my main Vim use case. So decided to look into how I can set up neovim to support that. These are my notes how to set up Neovim to support note taking and writing. These notes mainly serve me to understand how I can setup a reproducible config on Windows 11 running Debian Sid in WSL within Windows Terminal. ** Installation #+begin_note Neovim is [[https://packages.debian.org/search?keywords=neovim][in Debian]] but its latest stable lags several major versions behind the [[https://github.com/neovim/neovim/releases/tag/stable][upstream stable]], so installing with [[https://github.com/MordechaiHadad/bob][bob]]. #+end_note Install dependencies for bob: ~$ sudo aptitude install rustup~ ~$ cd ~/sources~ ~$ unzip bob-linux-x86_64.zip~ ~$ wget https://github.com/MordechaiHadad/bob/releases/download/v2.8.3/bob-linux-x86_64.zip~ ~$ cd bob-linux-x86_64/~ ~$ ./bob use stable~ Nvim is now installed. Check version installed: ~$ nvim -V1 -v~ #+begin_src bash NVIM v0.10.0-dev-2947+ge1ca7a7bf Build type: RelWithDebInfo LuaJIT 2.1.1710088188 Compilation: /usr/bin/gcc-10 -O2 -g -Og -g -flto=auto -fno-fat-lto-objects -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -fsigned-char -fstack-protector-strong -Wno-conversion -fno-common -Wno-unused-result -Wimplicit-fallthrough -fdiagnostics-color=always -DUNIT_TESTING -DHAVE_UNIBILIUM -D_GNU_SOURCE -DINCLUDE_GENERATED_DECLARATIONS -I/home/runner/work/neovim/neovim/.deps/usr/include/luajit-2.1 -I/home/runner/work/neovim/neovim/.deps/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include -I/home/runner/work/neovim/neovim/build/cmake.config -I/home/runner/work/neovim/neovim/src -I/usr/include system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/local/share/nvim" Run :checkhealth for more info #+end_src Then keep your installation up-to-date: ~$ ./bob update |nightly|stable|--all|~ #+BEGIN_COMMENT OR install using the latest binary: #+BEGIN_SRC bash $ curl -L -O https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz $ rm -rf "$HOME/sources/neovim" $ mkdir "$HOME/sources/neovim" $ tar xzvf nvim-linux64.tar.gz -C "$HOME/sources/neovim" $ sudo ln -sf "$HOME/sources/neovim/nvim-linux64/bin/nvim" "/usr/bin/nvim" $ rm "$HOME/sources/neovim/nvim-linux64.tar.gz" #+END_SRC #+END_COMMENT ** Post-installation tasks *** DONE symlink nvim So that [[https://github.com/MordechaiHadad/bob?tab=readme-ov-file#%EF%B8%8F-troubleshooting][sudo nvim works]]. ~$ sudo ln -s /home/pyyhttu/.local/share/bob/nvim-bin/nvim /usr/bin/nvim~ *** DONE Install nvim config ~$ git clone https://github.com/meuter/nvim ~/.config/nvim~ After this you have relatively sane config under =$XDG_CONFIG_HOME/nvim/lua=: ~$ tree~ Refactor the plugins to only include these: Then add org-mode, x and y: #+BEGIN_COMMENT ,*** DONE Install kickstart.nvim First install dependencies: ~$ sudo aptitude install build-essential gcc unzip git make ripgrep fd-find~ Otherwise you will get various [[https://github.com/nvim-treesitter/nvim-treesitter/issues/2811#issuecomment-1583652972][errors]] when nvim sources kickstart's =init.lua= such as: =No C compiler found! "cc", "gcc", "clang", "cl", "zig" are not executable.= After installing the dependencies, install =kickstart.nvim= by getting its =init.lua=: ~$ git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME:-$HOME/.config}"/nvim~ ,*** DONE Uninstall kickstart.nvim If you screw up and want to start over, as per [[https://github.com/folke/lazy.nvim#-uninstalling][instructions]], delete: data: ~sudo rm -r ~/.local/share/nvim~ \\ state: ~rm -r ~/.local/state/nvim~ \\ lockfile: ~sudo rm -r ~/.config/nvim~ \\ ,*** DONE Install manual As neovim binary was installed plainly with ~curl~ and ~tar~, remember to [[https://www.baeldung.com/linux/man-pages-manual-install#installing-man-pages-globally][copy the manual]] to its place: ~$ sudo cp ~/sources/neovim/nvim-linux64/man/man1/nvim.1 /usr/local/share/man/man1/~ in order to do ~$ man nvim~. #+END_COMMENT *** DONE Install [[https://neovim.io/doc/user/provider.html#clipboard-tool][clipboard support]] So that copying / pasting into / to nvim works. Easiest way to do this is with [[https://learn.microsoft.com/en-us/windows/package-manager/winget/][Winget]] and win32yank. Then launch =cmd.exe= and issue: ~winget install win32yank~ After this also mouse right click and copy/paste works as well as ="*y= yanking. ** Plugins =.config/nvim/lua/plugins/orgmode.lua=: #+BEGIN_SRC lua return { "nvim-orgmode/orgmode", event = "BufRead", -- replace VeryLazy, otherwise syntax highlighting won't work config = function() -- Setup orgmode require("orgmode").setup({ -- org_agenda_files = "~/orgfiles/**/*", org_agenda_files = "~/orgfiles/*", org_default_notes_file = "~/orgfiles/refile.org", }) -- NOTE: If you are using nvim-treesitter with `ensure_installed = "all"` option -- add `org` to ignore_install -- require('nvim-treesitter.configs').setup({ -- ensure_installed = 'all', -- ignore_install = { 'org' }, -- }) end, } #+END_SRC Install with these plugins: ** Maintenance ** Troubleshooting ** Observations and future direction *** DONE =init.vim= and =init.lua= Both files are [[https://herrbischoff.com/2022/07/neovim-using-init-vim-and-init-lua-concurrently/][not supported]] at the same time, but I can [[https://www.reddit.com/r/neovim/comments/zfimqo/is_it_possible_to_use_initvim_and_initlua_together/]["nest"]] =init.vim= config into =init.lua=, so write config with that. Here's a helpful [[https://neovim.io/doc/user/lua-guide.html][lua-guide]] to get started. There's also [[https://github.com/nvim-lua/kickstart.nvim][kickstart.nvim]] which goes through the config. Here's vhyrro's video on undetstanding [[https://www.reddit.com/r/neovim/comments/1bh9d3y/vhyrros_understanding_neovim_by_far_the_best/][Neovim]]. *** NEXT Go through the old =vimrc= and migrate config to =init.lua= #+begin_parallel [[color:blue][Are you excited to learn some Lisp?]] [[green:Yes!]] Pop-quiz: How does doc:apply work? #+end_parallel #+begin_details Answer link-here:solution Syntactically, ~(apply f '(x0 ... xN)) = (f x0 ... xN)~. [[remark:Musa][Ain't that cool?]] #+begin_spoiler aqua That is, [[color:magenta][we can ((apply)) a function to a list of arguments!]] #+end_spoiler #+end_details #+html:
#+begin_box octoicon:report Note that kbd:C-x_C-e evaluates a Lisp form! #+end_box #+LATEX_HEADER: \usepackage{multicol} #+LATEX_HEADER: \usepackage{tcolorbox} #+latex: In the LaTeX output, we have a glossary. show:GLOSSARY badge:Thanks|for_reading tweet:https://github.com/alhassy/org-special-block-extras badge:|buy_me_a coffee|gray|https://www.buymeacoffee.com/alhassy|buy-me-a-coffee * Footnotes