Neovim: Difference between revisions

From ArchWiki
m (→‎Tips and tricks: Remove trailing whitespace)
(→‎Loading plugins: Make vim-plug an AUR link)
 
(49 intermediate revisions by 20 users not shown)
Line 6: Line 6:
[[pt:Neovim]]
[[pt:Neovim]]
[[zh-hans:Neovim]]
[[zh-hans:Neovim]]
[https://neovim.io/ Neovim] is a fork of [[Vim]] aiming to improve the codebase, allowing for easier implementation of APIs, improved user experience and plugin implementation.
[https://neovim.io/ Neovim] is a fork of [[Vim]] aiming to improve the codebase, allowing for easier implementation of APIs, improved user experience and plugin implementation. Neovim inspired editors like [[Helix]].


== Installation ==
== Installation ==


[[Install]] the {{Pkg|neovim}} package, or {{AUR|neovim-git}} for the latest development version, which strongly encourages the use of [[Lua]] as its main configuration language. To make the system clipboard work with Neovim, you may need to install {{Pkg|xclip}} (X11) or {{Pkg|wl-clipboard}} (Wayland).  
[[Install]] the {{Pkg|neovim}} package, or {{AUR|neovim-git}} for the latest development version, which strongly encourages the use of [[Lua]] as its main configuration language. To make the system clipboard work with Neovim, you may need to install {{Pkg|xclip}} (X11) or {{Pkg|wl-clipboard}} (Wayland).


{{Note|With neovim, some of its features are delegated to external "providers". For Python providers, use {{Pkg|python-pynvim}}.
{{Note|With neovim, some of its features are delegated to external "providers". For Python providers, use {{Pkg|python-pynvim}}. For clipboard providers, see [https://neovim.io/doc/user/provider.html#provider-clipboard provider-clipboard] or the {{ic|:help provider-clipboard}} neovim command.}}
For clipboard providers, see [https://neovim.io/doc/user/provider.html#provider-clipboard provider-clipboard] or the {{ic|:help provider-clipboard}} neovim command.}}


It is also possible to install one of [https://github.com/neovim/neovim/wiki/Related-projects many GUIs and other related projects], most of them are in [[official repositories]] or in [[AUR]]:
It is also possible to install one of [https://github.com/neovim/neovim/wiki/Related-projects many GUIs and other related projects]:


* {{Pkg|neovim-qt}}
* {{App|{{Pkg|neovim-qt}}|Fast, lightweight, and customizable Qt GUI. Provides a modern interface, including support for multiple tabs, split windows, and customizable themes.|https://github.com/equalsraf/neovim-qt|{{Pkg|neovim-qt}}}}
* {{AUR|neovim-gtk}} or {{AUR|neovim-gtk-git}}
* {{App|{{AUR|neovim-gtk}}|GTK GUI. Provides a modern, customizable interface, including support for split windows, multiple tabs, and customizable themes.|https://github.com/Lyude/neovim-gtk|{{AUR|neovim-gtk}}}}
* {{AUR|uivonim-git}}
* {{App|{{AUR|uivonim-git}}|([https://aur.archlinux.org/packages/uivonim-git#comment-888471 Inactive]) Simple and lightweight GTK GUI. Provides a minimalistic interface, including support for split windows and customizable themes.|{{AUR|uivonim-git}}|{{AUR|uivonim-git}}}}
* {{AUR|neovide-git}}, {{AUR|neovide}} or {{AUR|neovide-bin}}
* {{App|{{Pkg|neovide}}|Rust GUI.|https://github.com/neovide/neovide|{{Pkg|neovide}}}}
* {{AUR|neoray-git}}
* {{App|{{AUR|neoray-git}}|Go GUI.|https://github.com/hismailbulut/neoray|{{AUR|neoray-git}}}}
* {{AUR|gnvim}}
* {{App|{{AUR|gnvim}}|GTK GUI.|https://github.com/vhakulinen/gnvim|{{AUR|gnvim}}}}
* {{AUR|fvim}}
* {{App|{{AUR|fvim}}|F# GUI.|https://github.com/yatli/fvim|{{AUR|fvim}}}}


== Configuration ==
== Configuration ==


Nvim's user-specific configuration file is located at {{ic|$XDG_CONFIG_HOME/nvim/init.vim}}, by default {{ic|~/.config/nvim/init.vim}}. The global configuration file is loaded from {{ic|$XDG_CONFIG_DIRS/nvim/sysinit.vim}} (by default {{ic|/etc/xdg/nvim/sysinit.vim}}) if it exists, or if it does not, from {{ic|/usr/share/nvim/sysinit.vim}} which should not be user-edited. [https://github.com/neovim/neovim/blob/master/runtime/doc/starting.txt#L437] By default, the former global configuration file does not exist. If you create the former file, you may wish to have it source the latter if you still want the functionality it provides, which is allowing pacman-installed vim packages to work with Nvim.
Nvim's user-specific configuration file is located at {{ic|$XDG_CONFIG_HOME/nvim/init.vim}}, by default {{ic|~/.config/nvim/init.vim}}. The system-wide configuration file is located at {{ic|$XDG_CONFIG_DIRS/nvim/sysinit.vim}}, by default {{ic|/etc/xdg/nvim/sysinit.vim}}. When the system-wide configuration file does not exist, Nvim checks for {{ic|/usr/share/nvim/sysinit.vim}}, which is not intended to be edited by users.[https://github.com/neovim/neovim/blob/master/runtime/doc/starting.txt#L439] By default, the former global configuration file does not exist. If you create the former file, you may wish to have it source the latter if you still want the functionality it provides, which is allowing pacman-installed vim packages to work with Nvim.


Nvim is compatible with most of Vim's options, however there are options specific to Nvim. For a complete list of Nvim options, see Neovim's [https://neovim.io/doc/user/options.html help file].
Nvim is compatible with most of Vim's options; however, there are options specific to Nvim. For a complete list of Nvim options, see Neovim's [https://neovim.io/doc/user/options.html help file].


Nvim's data directory is located in {{ic|~/.local/share/nvim/}} and contains swap for open files, the [https://neovim.io/doc/user/starting.html#shada ShaDa] (Shared Data) file, and the site directory for plugins.
Nvim's data directory is located in {{ic|~/.local/share/nvim/}} and contains swap for open files, the [https://neovim.io/doc/user/starting.html#shada ShaDa] (Shared Data) file, and the site directory for plugins.


Starting from Nvim's version 0.5, it is possible to setup Nvim via Lua, by default {{ic|~/.config/nvim/init.lua}}, the API is still young, but common configurations work out-of-the-box without much more steps. See [https://github.com/nanotee/nvim-lua-guide] for suggestions on how to convert your current configuration. At the moment there is is not much of an advantage when using {{ic|init.lua}} vs the common {{ic|init.vim}}, but when correctly done, Lua provides a small improvement in startup times, and it becomes specially useful when using several plugins written in lua, due to ease of configuration.
Starting from Nvim's version 0.5, it is possible to setup Nvim via Lua, by default {{ic|~/.config/nvim/init.lua}}, the API is still young, but common configurations work out-of-the-box without much more steps. See [https://github.com/nanotee/nvim-lua-guide] for suggestions on how to convert your current configuration. At the moment, there is not much of an advantage when using {{ic|init.lua}} vs the common {{ic|init.vim}}, but when correctly done, Lua provides a small improvement in startup times, and it becomes specially useful when using several plugins written in Lua, due to ease of configuration.


=== Migrating from Vim ===
=== Migrating from Vim ===
Line 39: Line 38:
If you wish to migrate your existing Vim configuration to Nvim, simply copy your {{ic|~/.vimrc}} to {{ic|~/.config/nvim/init.vim}}. If applicable, copy the contents of {{ic|~/.vim/autoload/}} to {{ic|~/.local/share/nvim/site/autoload/}}.
If you wish to migrate your existing Vim configuration to Nvim, simply copy your {{ic|~/.vimrc}} to {{ic|~/.config/nvim/init.vim}}. If applicable, copy the contents of {{ic|~/.vim/autoload/}} to {{ic|~/.local/share/nvim/site/autoload/}}.


=== Shared Configuration between Vim and Nvim ===
=== Shared configuration between Vim and Nvim ===


Neovim uses {{ic|$XDG_CONFIG_HOME/nvim}} instead of {{ic|~/.vim}} as its main configuration directory and {{ic|$XDG_CONFIG_HOME/nvim/init.vim}} instead of {{ic|~/.vimrc}} as its main configuration file.
Neovim uses {{ic|$XDG_CONFIG_HOME/nvim}} instead of {{ic|~/.vim}} as its main configuration directory and {{ic|$XDG_CONFIG_HOME/nvim/init.vim}} instead of {{ic|~/.vimrc}} as its main configuration file.
Line 47: Line 46:
==== Loading plugins ====
==== Loading plugins ====


Vim/Nvim plugins installed from [[official repositories]] or [[AUR]] get automatically sourced by {{ic|/etc/xdg/nvim/sysinit.vim}}, so there is no need to take any extra steps. A vast amount of plugins can be found on both places, but the most recommended way to add plugins is by using a plugin manager, most commonly used are [https://github.com/junegunn/vim-plug vim-plug] which works for both Vim and Nvim, and [https://github.com/wbthomason/packer.nvim packer] which only works on Nvim 0.5 or newer and is written in lua. Both of them allow for expressive configurations, ranging from github branch to runtime commands.
Vim/Nvim plugins installed from [[official repositories]] or [[AUR]] get automatically sourced by {{ic|/etc/xdg/nvim/sysinit.vim}}, so there is no need to take any extra steps. A vast amount of plugins can be found on both places, but the most recommended way to add plugins is by using a plugin manager, most commonly used are {{AUR|vim-plug}} which works for both Vim and Nvim, and [https://github.com/wbthomason/packer.nvim packer] which only works on Nvim 0.5 or newer and is written in Lua. Both of them allow for expressive configurations, ranging from github branch to runtime commands.


Most plugins written for vim work without much effort on Nvim, but not every plugin written for Nvim works for Vim, so if your intention is to ensure a compatible configuration, stick to a traditional {{ic|init.vim}} or {{ic|.vimrc}}
Most plugins written for vim work without much effort on Nvim, but not every plugin written for Nvim works for Vim, so if your intention is to ensure a compatible configuration, stick to a traditional {{ic|init.vim}} or {{ic|.vimrc}}
Line 57: Line 56:
Setting {{ic|$VISUAL}} and {{ic|$EDITOR}} [[environment variables]] should be sufficient in most cases.
Setting {{ic|$VISUAL}} and {{ic|$EDITOR}} [[environment variables]] should be sufficient in most cases.


Some applications may hardcode vi or vim as default editor, to use ''neovim'' in their place, install {{AUR|neovim-symlinks}} or {{AUR|neovim-drop-in}}.
Some applications may hardcode vi or vim as default editor; to use ''neovim'' in their place, install {{AUR|neovim-symlinks}} or {{AUR|neovim-drop-in}}.


=== Symlinking init.vim to .vimrc ===
=== Symlinking init.vim to .vimrc ===


As neovim is mostly compatible with standard vim, you can symlink {{ic|nvim/init.vim}} to your old {{ic|.vimrc}} to keep old configuration options:
As neovim is ''mostly'' compatible with standard vim, you can symlink {{ic|nvim/init.vim}} to your old {{ic|.vimrc}} to keep old configuration options:


  $ ln -s ~/.vimrc ~/.config/nvim/init.vim
  $ ln -s ~/.vimrc ~/.config/nvim/init.vim


If you want some lines to be specific to each version, you can use an {{ic|if}} block in your {{ic|.vimrc}} file:
If you want some lines to be specific to each version, you can use an {{ic|if}} block:


if has('nvim')
{{hc|.vimrc|
    " Neovim specific commands
if has('nvim')
else
    " Neovim specific commands
    " Standard vim specific commands
else
endif
    " Standard vim specific commands
endif
}}


=== Adding true color support to neovim ===
=== True color support ===


The {{ic|READMEs}} of [https://github.com/CarloWood/neovim-true-color-scheme-editor this project] explain how to add 24-bits "True Color" support to your syntax highlighting and how to use a color picker to see how it looks in real-time. Comes with the syntax highlighting of the author (if installed) for C++.
The {{ic|READMEs}} of [https://github.com/CarloWood/neovim-true-color-scheme-editor this project] explain how to add 24-bits "True Color" support to your syntax highlighting and how to use a color picker to see how it looks in real-time. Comes with the syntax highlighting of the author (if installed) for C++.
=== Lastplace cursor support ===
If you like to keep your last position of cursor to be saved, [https://github.com/neovim/neovim/issues/16339#issuecomment-1348133829 lastplace.lua] is quite useful. It just needs to be placed in {{ic|~/.config/nvim/plugin/}} or in the system-wide directory {{ic|/usr/share/nvim/runtime/plugin/}}.


=== Language Server Protocol ===
=== Language Server Protocol ===
Line 81: Line 86:
Neovim contains a built-in [https://microsoft.github.io/language-server-protocol Language Server Protocol] client and the [https://github.com/neovim/nvim-lspconfig nvim-lspconfig] plugin provides common configurations for it.
Neovim contains a built-in [https://microsoft.github.io/language-server-protocol Language Server Protocol] client and the [https://github.com/neovim/nvim-lspconfig nvim-lspconfig] plugin provides common configurations for it.


Language servers can be installed natively using the following packages:
See [[Language Server Protocol]] for a list of Arch packages.
 
=== Use as a pager ===
 
You can use the {{ic|:Man}} command to open manual pages. To open all manual pages with neovim set the {{ic|MANPAGER}} [[environment variable]] to {{ic|nvim +Man!}}.
 
For other pager support install either the {{AUR|nvimpager}} or the {{AUR|nvimpager-git}} package and set the {{ic|PAGER}} [[environment variable]] to {{ic|nvimpager}}.


{| class="wikitable"
You can also try [https://github.com/I60R/page page], packaged in {{AUR|page-git}}.
! LSP config
! Language
! LSP server package
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#als als]
| Ada/SPARK
| {{AUR|ada_language_server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#angularls angularls]
| Angular
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#bashls bashls]
| BASH
| {{Pkg|bash-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#ccls ccls]
| C, C++, Objective-C
| {{Pkg|ccls}} {{AUR|ccls-git}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#clangd clangd]
| C++
| {{Pkg|clang}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#clojure_lsp clojure_lsp]
| Clojure
| {{AUR|clojure-lsp-bin}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#cmake cmake]
| CMake
| {{AUR|cmake-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#codeqlls codeqlls]
| CodeQL
| {{AUR|codeql}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#cssls cssls]
| CSS, LESS, SASS
| {{Pkg|vscode-css-languageserver}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#dartls dartls]
| Dart
| {{Pkg|dart}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#denols denols]
| JavaScript, TypeScript
| {{Pkg|deno}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#dhall_lsp_server dhall_lsp_server]
| Dhall
| {{Pkg|dhall-lsp-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#diagnosticls diagnosticls]
| General purpose
| {{AUR|diagnostic-languageserver}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#dockerls dockerls]
| Dockerfile
| {{AUR|dockerfile-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#efm efm]
| General purpose
| {{AUR|efm-langserver}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#elixirls elixirls]
| Elixir
| {{AUR|elixir-ls}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#elmls elmls]
| Elm
| {{AUR|elm-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#erlangls erlangls]
| Erlang
| {{AUR|erlang_ls-git}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#flow flow]
| Flow
| {{AUR|flow}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#fortls fortls]
| Fortran
| {{AUR|fortran-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#fsautocomplete fsautocomplete]
| F#
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#gdscript gdscript]
| GDScript
| {{Pkg|godot}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#ghcide ghcide]
| Haskell
| {{AUR|ghcide}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#gopls gopls]
| GOlang
| {{Pkg|gopls}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#graphql graphql]
| GraphQL
| {{AUR|graphql-lsp}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#groovyls groovyls]
| Groovy
| {{AUR|groovy-language-server-git}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#haxe_language_server haxe_language_server]
| Haxe
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#hie hie]
| Haskell
| {{AUR|haskell-ide-engine}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#hls hls]
| Haskell
| {{Pkg|haskell-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#html html]
| HTML
| {{Pkg|vscode-html-languageserver}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#intelephense intelephense]
| PHP
| {{AUR|nodejs-intelephense}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#java_language_server java_language_server]
| Java
| {{AUR|java-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#jdtls jdtls]
| Java
| {{AUR|jdtls}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#jedi_language_server jedi_language_server]
| Python
| {{Pkg|jedi-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#jsonls jsonls]
| JSON
| {{Pkg|vscode-json-languageserver}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#julials julials]
| Julia
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#kotlin_language_server kotlin_language_server]
| Kotlin
| {{AUR|kotlin-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#leanls leanls]
| Lean
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#metals metals]
| Scala
| {{AUR|metals}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#nimls nimls]
| Nim
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#ocamlls ocamlls]
| OCaml, Reason
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#ocamllsp ocamllsp]
| OCaml, Reason
| {{AUR|ocaml-lsp-git}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#omnisharp omnisharp]
| OmniSharp
| {{AUR|omnisharp-roslyn}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#perlls perlls]
| Perl
| {{AUR|perl-perl-languageserver}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#phpactor phpactor]
| PHP
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#powershell_es powershell_es]
| PowerShell
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#purescriptls purescriptls]
| PureScript
| {{AUR|purescript-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#pylsp pylsp]
| Python
| {{Pkg|python-lsp-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#pyright pyright]
| Python
| {{Pkg|pyright}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#r_language_server r_language_server]
| R
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#racket_langserver racket_langserver]
| Racket
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rescriptls rescriptls]
| ReScript
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rls rls]
| Rust
| {{AUR|rls-git}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rnix rnix]
| nix
| {{AUR|rnix-lsp-git}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rome rome]
| Rome
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer rust_analyzer]
| Rust
| {{Pkg|rust-analyzer}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#scry scry]
| Crystal
| {{AUR|scry-git}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#solargraph solargraph]
| Ruby
| {{AUR|ruby-solargraph}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sorbet sorbet]
| Ruby
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sourcekit sourcekit]
| C, C++, Objective-C
| {{AUR|swift-language}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sqlls sqlls]
| SQL
| {{AUR|sql-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sqls sqls]
| SQL
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#stylelint_lsp stylelint_lsp]
| stylelint
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sumneko_lua sumneko_lua]
| Lua
| {{Pkg|lua-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#svelte svelte]
| Svelte
| {{AUR|nodejs-svelte-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#svls svls]
| SystemVerilog
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#terraformls terraformls]
| Terraform
| {{AUR|terraform-ls}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#texlab texlab]
| (La)TeX
| {{Pkg|texlab}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#tflint tflint]
| Terraform
| {{AUR|tflint}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#tsserver tsserver]
| TypeScript
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#vala_ls vala_ls]
| Vala
| {{AUR|vala-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#vimls vimls]
| Vim
| {{AUR|vim-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#vls vls]
| V
|
|-
| [https://github.com/johnsoncodehk/volar/tree/master/packages/vue-language-server volar]
| Vue 3
| {{AUR|volar-server-bin}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#vuels vuels]
| Vue 2
| {{AUR|nodejs-vls}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#yamlls yamlls]
| YAML
| {{Pkg|yaml-language-server}}
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#zeta_note zeta_note]
| Markdown
|
|-
| [https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#zls zls]
| Zig
| {{AUR|zls-bin}}
|}


== Troubleshooting ==
== Troubleshooting ==
Line 405: Line 100:
=== Cursor is not restored to previous state after exit ===
=== Cursor is not restored to previous state after exit ===


If after exiting neovim cursor is still blinking see solution on [https://github.com/neovim/neovim/wiki/FAQ#cursor-style-isnt-restored-after-exiting-nvim neovim FAQ].
If the cursor keeps blinking after exiting neovim, see the solution in the [https://github.com/neovim/neovim/wiki/FAQ#cursor-style-isnt-restored-after-exiting-or-suspending-and-resuming-nvim neovim FAQ].


== See also ==
== See also ==

Latest revision as of 14:23, 13 April 2024

Neovim is a fork of Vim aiming to improve the codebase, allowing for easier implementation of APIs, improved user experience and plugin implementation. Neovim inspired editors like Helix.

Installation

Install the neovim package, or neovim-gitAUR for the latest development version, which strongly encourages the use of Lua as its main configuration language. To make the system clipboard work with Neovim, you may need to install xclip (X11) or wl-clipboard (Wayland).

Note: With neovim, some of its features are delegated to external "providers". For Python providers, use python-pynvim. For clipboard providers, see provider-clipboard or the :help provider-clipboard neovim command.

It is also possible to install one of many GUIs and other related projects:

  • neovim-qt — Fast, lightweight, and customizable Qt GUI. Provides a modern interface, including support for multiple tabs, split windows, and customizable themes.
https://github.com/equalsraf/neovim-qt || neovim-qt
  • neovim-gtkAUR — GTK GUI. Provides a modern, customizable interface, including support for split windows, multiple tabs, and customizable themes.
https://github.com/Lyude/neovim-gtk || neovim-gtkAUR
  • uivonim-gitAUR — (Inactive) Simple and lightweight GTK GUI. Provides a minimalistic interface, including support for split windows and customizable themes.
uivonim-gitAUR || uivonim-gitAUR
https://github.com/neovide/neovide || neovide
https://github.com/hismailbulut/neoray || neoray-gitAUR
https://github.com/vhakulinen/gnvim || gnvimAUR
https://github.com/yatli/fvim || fvimAUR

Configuration

Nvim's user-specific configuration file is located at $XDG_CONFIG_HOME/nvim/init.vim, by default ~/.config/nvim/init.vim. The system-wide configuration file is located at $XDG_CONFIG_DIRS/nvim/sysinit.vim, by default /etc/xdg/nvim/sysinit.vim. When the system-wide configuration file does not exist, Nvim checks for /usr/share/nvim/sysinit.vim, which is not intended to be edited by users.[1] By default, the former global configuration file does not exist. If you create the former file, you may wish to have it source the latter if you still want the functionality it provides, which is allowing pacman-installed vim packages to work with Nvim.

Nvim is compatible with most of Vim's options; however, there are options specific to Nvim. For a complete list of Nvim options, see Neovim's help file.

Nvim's data directory is located in ~/.local/share/nvim/ and contains swap for open files, the ShaDa (Shared Data) file, and the site directory for plugins.

Starting from Nvim's version 0.5, it is possible to setup Nvim via Lua, by default ~/.config/nvim/init.lua, the API is still young, but common configurations work out-of-the-box without much more steps. See [2] for suggestions on how to convert your current configuration. At the moment, there is not much of an advantage when using init.lua vs the common init.vim, but when correctly done, Lua provides a small improvement in startup times, and it becomes specially useful when using several plugins written in Lua, due to ease of configuration.

Migrating from Vim

If you wish to migrate your existing Vim configuration to Nvim, simply copy your ~/.vimrc to ~/.config/nvim/init.vim. If applicable, copy the contents of ~/.vim/autoload/ to ~/.local/share/nvim/site/autoload/.

Shared configuration between Vim and Nvim

Neovim uses $XDG_CONFIG_HOME/nvim instead of ~/.vim as its main configuration directory and $XDG_CONFIG_HOME/nvim/init.vim instead of ~/.vimrc as its main configuration file.

If you wish to continue using Vim and wish to source your existing Vim configuration in Nvim, see nvim-from-vim or the :help nvim-from-vim neovim command.

Loading plugins

Vim/Nvim plugins installed from official repositories or AUR get automatically sourced by /etc/xdg/nvim/sysinit.vim, so there is no need to take any extra steps. A vast amount of plugins can be found on both places, but the most recommended way to add plugins is by using a plugin manager, most commonly used are vim-plugAUR which works for both Vim and Nvim, and packer which only works on Nvim 0.5 or newer and is written in Lua. Both of them allow for expressive configurations, ranging from github branch to runtime commands.

Most plugins written for vim work without much effort on Nvim, but not every plugin written for Nvim works for Vim, so if your intention is to ensure a compatible configuration, stick to a traditional init.vim or .vimrc

Tips and tricks

Replacing vi and vim with neovim

Setting $VISUAL and $EDITOR environment variables should be sufficient in most cases.

Some applications may hardcode vi or vim as default editor; to use neovim in their place, install neovim-symlinksAUR or neovim-drop-inAUR.

Symlinking init.vim to .vimrc

As neovim is mostly compatible with standard vim, you can symlink nvim/init.vim to your old .vimrc to keep old configuration options:

$ ln -s ~/.vimrc ~/.config/nvim/init.vim

If you want some lines to be specific to each version, you can use an if block:

.vimrc
if has('nvim')
    " Neovim specific commands
else
    " Standard vim specific commands
endif

True color support

The READMEs of this project explain how to add 24-bits "True Color" support to your syntax highlighting and how to use a color picker to see how it looks in real-time. Comes with the syntax highlighting of the author (if installed) for C++.

Lastplace cursor support

If you like to keep your last position of cursor to be saved, lastplace.lua is quite useful. It just needs to be placed in ~/.config/nvim/plugin/ or in the system-wide directory /usr/share/nvim/runtime/plugin/.

Language Server Protocol

Neovim contains a built-in Language Server Protocol client and the nvim-lspconfig plugin provides common configurations for it.

See Language Server Protocol for a list of Arch packages.

Use as a pager

You can use the :Man command to open manual pages. To open all manual pages with neovim set the MANPAGER environment variable to nvim +Man!.

For other pager support install either the nvimpagerAUR or the nvimpager-gitAUR package and set the PAGER environment variable to nvimpager.

You can also try page, packaged in page-gitAUR.

Troubleshooting

Cursor is not restored to previous state after exit

If the cursor keeps blinking after exiting neovim, see the solution in the neovim FAQ.

See also