- Neovim configuration on Windows 10
- Contents
- Before we begin
- Install
- Configuration
- Where to put the configuration file?
- Install plugin-manager vim-plug
- Issues
- The Neovim window content is not cleared when I exit
- Can not enter Neovim if there are errors in config file
- Some shortcuts do not work
- Shortcut conflict with Cmder
- does not work?
- References
- Neovim windows config path
- Ответы (3)
- Neovim windows config path
- About
- Neovim Windows init.vim location #3700
- Comments
- jrock2004 commented Nov 18, 2015
- timfeirg commented Nov 18, 2015
- mhinz commented Nov 18, 2015
- RedX2501 commented Dec 16, 2015
- masaeedu commented May 10, 2017 •
- johnrichardrinehart commented May 30, 2017
- justinmk commented May 30, 2017
- johnrichardrinehart commented May 30, 2017
- justinmk commented May 30, 2017 •
- johnrichardrinehart commented May 30, 2017
- justinmk commented May 30, 2017
- johnrichardrinehart commented May 30, 2017
- justinmk commented May 30, 2017
- johnrichardrinehart commented May 30, 2017
- justinmk commented May 30, 2017
- johnrichardrinehart commented May 30, 2017
- justinmk commented May 30, 2017
Neovim configuration on Windows 10
Contents
update: 2020-11-15, add detailed instruction for Neovim config location.
TL;DR: After nearly one year of using Neovim on Windows, I find that the best experience one can get on Windows is to use GUI Neovim client such as Nvim-qt or fvim, not the terminal Nvim 1 .
In this post, I want to share how to install and configure Neovim on Windows 10 2 . For configurations of nvim-qt on Windows, check this post.
Before we begin
The builtin CMD on Windows is awful and lacks features of a normal Linux terminal. I strongly recommend readers using a better terminal emulator, for example, Cmder, which comes with Git for Windows and other utilities for you.
Install
You can download the neovim nightly release from its GitHub repo. Then extract the package, add the extracted folder to your system PATH variable, and make sure that you can invoke nvim on the command line.
See here for other ways to install Neovim on Windows.
Configuration
Where to put the configuration file?
A common confusion for novice users of Neovim is that they do not know where to put the config files. It is in fact quite simple.
First of all, the neovim config file is named init.vim regardless of your system.
Second, based on Neovim official documentation, you should put init.vim under the directory
/AppData/Local/nvim on Windows. To find here that directory is exactly, use the command :echo stdpath(‘config’) inside Neovim.
If this directory does not exist, do not worry. Just create it and put your config file there.
Install plugin-manager vim-plug
vim-plug is popular plugin manager for Neovim. To install it on Windows, open a PowerShell terminal (not Windows CMD!), and execute the following command:
In init.vim , use the following settings for vim-plug:
When we run command :PlugInstall , all the plugins will be installed under
/AppData/Local/nvim/plugged . We can also change this directory to where we want, for example,
Issues
The Neovim window content is not cleared when I exit
When I exit Neovim, the text content inside the buffer is still shown in the command line, wasting a lot of space. How do we clear the Neovim window content after exit?
After some research, I have finally found a solution that works for Cmder. Open Cmder settings and go to Startup -> Environment , add the following settings:
Restart Cmder and the issue should disappear. More discussions can be found here.
Can not enter Neovim if there are errors in config file
If there are errors in init.vim , Neovim will prompt you the following message during startup:
Press ENTER or type command to continue
However, pressing Enter has no effect. Neovim will hang unless you press Ctrl-C to terminate the process.
To circumvent this issue, according to this issue, try to open Neovim with the following option:
Some shortcuts do not work
Shortcut conflict with Cmder
For Cmder, Ctrl-W is used to close a console. Unfortunately, this shortcut is also used by Neovim as prefix for window operations. Maybe there are some other conflicting shortcuts, for example, Ctrl-V does work like Linux.
To disable the conflicting shortcuts in Cmder, go to Keys & Macro part to change or disable a shortcut.
does not work?
On Linux, we can use Ctrl-^ (actually Ctrl-6 ) to switch buffers. However, on Windows, using for buffer switching does not work in terminal nvim. I try to map Ctrl-6 to Ctrl-^ :
It doesn’t work either. Until I find the solution , I use Ctrl+shift+6 to switch buffers.
My complete configurations for Neovim can be found in this repo. For How to configure Neovim for Python development, check this post.
References
Maybe the situation will change after Microsoft’s windows terminal become mature enough. ↩︎
Neovim windows config path
8120 просмотра
3 ответа
Есть ли у NeoVim свой собственный конфигурационный файл, как у vim .vimrc ? Если да, где я могу получить этот файл в домашнем каталоге, чтобы внести свои собственные изменения.
Ответы (3)
15 плюса
И Vim 8.0, и Neovim имеют свой встроенный менеджер пакетов. В Vim 8.0 создайте следующие каталоги:
.vim / pack / * / start, где * может быть любым именем; e, g, .vim / pack / jimmy / start. Клонируйте нужный плагин в каталог «start» так же, как если бы вы устанавливали его для pathogen. Вам больше ничего не нужно и никаких команд в вашем файле .vimrc. Вы можете использовать каталог ‘opt’ (.vim / pack / jimmy / opt) для плагинов, которые нужно загружать только по мере необходимости. Для цветов добавьте каталог в каталог opt, а затем свои цвета; например .vim / pack / jimmy / opt / mycolors / colors / dracula.vim.
Для Neovim структура каталогов немного длиннее (я не знаю почему!). Ваш конфигурационный файл находится в .config / nvim / init.vim, но ваши плагины идут в:
.local / share / nvim / site / pack / * / start и т. д.
Есть некоторая информация, доступная внутри neovim, набрав:: h packages.
2 плюса
попробуйте :h init.vim или :h vimrc . Вы увидите там всю информацию, которую вы ищете.
Предполагая, что вы работаете на Unix-машине: Если вы все еще хотите этот файл в вашем домашнем каталоге, вы можете использовать символическую ссылку там:
При желании вы можете запустить nvim с флагом -u и сообщить ему, что вы хотите использовать в качестве файла инициализации, чтобы вы могли просто nvim -u
/.vimrc . Наконец, вы можете добавить следующее в ваш файл инициализации терминала (.bashrc / .zshrc или любой другой терминал, который вы используете), alias vim=’nvim -u
/.vimrc’ если вы действительно хотите использовать этот файл в своем домашнем каталоге, не вставляя ссылки, но я бы не советовал работать с этим путь
0 плюса
Конфигурационный файл Neovim назван, init.vim и его расположение различается в зависимости от вашей системы:
- Linux (включая Mac):
Все ваши настройки могут быть помещены в этот файл. Вы можете найти мой пример конфигурации здесь для справки.
Что касается установки плагинов, то для новичков легко использовать менеджер плагинов, чтобы сделать всю работу за вас. Vim-Plug — хороший выбор. Вы можете использовать его как на Windows, Linux и Mac. Это быстро. Следуйте документации по vim-plug, чтобы узнать, как его использовать.
Вы можете попробовать другой менеджер плагинов: dein , vundle .
Neovim windows config path
Collection of common configurations for Neovim’s built-in language server client. The configurations are supported on a best-effort basis, and rely on contributions from regular users to stay up-to-date.
This repo handles automatically launching, initializing, and configuring language servers that are installed on your system.
Requires Neovim HEAD/nightly (v0.5 prerelease). The configs in this repo assume that you are using the latest Neovim HEAD/nightly build. Update Neovim and nvim-lspconfig before reporting an issue.
nvim-lspconfig is just a plugin. Install it like any other Vim plugin, e.g. with vim-plug:
- Install a language server, e.g. pyright via npm i -g pyright
- Install nvim-lspconfig via your plugin manager
- Add the language server setup to your init.vim. The server name must match those found in the table of contents in CONFIG.md
- Open a file that is placed in a directory recognized by the server (see server configuration in CONFIG.md; e.g., for pyright, this is any directory containing «.git», «setup.py», «setup.cfg», «pyproject.toml», or «requirements.txt»)
- See Keybindings and completion for mapping useful functions and enabling omnifunc completion
- :LspInfo shows the status of active and configured language servers.
The following support tab-completion for all arguments:
- :LspStart Start the requested server name. Will only succesfully start if the command detects a root directory matching the current config. Pass autostart = false to your .setup<> call for a language server if you would like to launch clients solely with this command. Defaults to all servers matching current buffer filetype.
- :LspStop Defaults to stopping all buffer clients.
- :LspRestart Defaults to restarting all buffer clients.
All provided examples are in Lua, see :help :lua-heredoc to use Lua from your init.vim, or the quickstart above for an example of a lua heredoc.
Each config provides a setup() function to initialize the server with reasonable default initialization options and settings, as well as some server-specific commands. This is invoked in the following form, where corresponds to the language server name in CONFIG.md.
setup() takes optional arguments , each of which overrides the respective part of the default configuration. The allowed arguments are detailed below.
Example: using the defaults
To use the defaults, just call setup() with an empty config parameter. For the gopls config, that would be:
Example: override some defaults
To set some config properties at setup() , specify their keys. For example to change how the «project root» is found, set the root_dir key:
The documentation for each config lists default values and additional optional properties. For a more complicated example overriding the name , log_level , message_level , and settings of texlab:
Example: custom config
To configure a custom/private server, just
- load the lspconfig module: local lspconfig = require(‘lspconfig’) ,
- Define the config: lspconfig.configs.foo_lsp =
- Call setup() : lspconfig.foo_lsp.setup<>
Example: override default config for all servers
If you want to change default configs for all servers, you can override default_config like this. In this example, we additionally add a check for log_level and message_level which can be passed to the server to control the verbosity of «window/logMessage».
Individual server settings and initialization options
See CONFIG.md for documentation and configuration of individual language servers. This document contains installation instructions for each language server, and is auto-generated from the documentation in the lua source. Do not submit PRs modifying CONFIG.md directly; CONFIG.md will be overwritten by docgen
You do not need to copy settings or init_options from this configuration into your config
Keybindings and completion
The following maps most of the standard functions to keybindings, and maps omnicomplete to use the lsp.omnifunc. See :help lsp for more details
Please see the wiki for additional topics, including:
Only the following arguments can be passed to the setup function:
The two most common points of failure are
The language server is not installed. You should be able to run the cmd defined in each lua module from the command line.
Not triggering root detection. The language server will only start if it is opened in a directory, or child directory, containing a file which signals the root of the project. Most of the time, this is a .git folder, but each server defines the root config in the lua file.
:LspInfo provides a handy overview of your active and configured language servers. Note, that it will not report any configuration changes applied in on_new_config .
Before reporting a bug, check your logs and the output of :LspInfo . Add the following to your init.vim to enable logging
Attempt to run the language server, and open the log with:
Most of the time, the reason for failure is present in the logs.
In order for neovim to launch certain executables on Windows, it must append .cmd to the command name. A fix is in the works upstream, but until this is mainlined please the following somewhere in your init.vim (lua heredoc) or init.lua:
If you are missing a language server on the list in CONFIG.md, contributing a new configuration for it would be appreciated. You can follow these steps:
- Read CONTRIBUTING.md.
- Choose a language from the coc.nvim wiki or emacs-lsp.
- Create a new file at lua/lspconfig/SERVER_NAME.lua .
- Copy an existing config to get started. Most configs are simple. For an extensive example see texlab.lua.
- Ask questions on our Discourse or in Neovim Gitter.
About
Quickstart configurations for the Nvim LSP client
Neovim Windows init.vim location #3700
Comments
jrock2004 commented Nov 18, 2015
Is the location of init.vim the same as it is on my mac and Linux?
The text was updated successfully, but these errors were encountered:
timfeirg commented Nov 18, 2015
see :h nvim-from-vim , use soft link and don’t worry about the locations of neovim config files
better take this to gitter as this is not really a neovim issue
mhinz commented Nov 18, 2015
RedX2501 commented Dec 16, 2015
The alternative paths for windows information should definitely go into nvim_from_vim.txt and Following HEAD wiki page.
masaeedu commented May 10, 2017 •
@mhinz Is this configurable? I’d rather not change where my vimrc files are located as I have them set up for sync.
johnrichardrinehart commented May 30, 2017
I am also wondering whether or not this is configurable.
justinmk commented May 30, 2017
:help xdg , :help nvim-from-vim
johnrichardrinehart commented May 30, 2017
@justinmk, I had read those docs, already, from which it seems that neovim has made the design choice to not allow for this to be configured. However, I thought my question might prompt a discussion as to whether or not including such a configuration option would be considered.
justinmk commented May 30, 2017 •
Configure how? An environment variable? That would be the XDG vars, already supported.
johnrichardrinehart commented May 30, 2017
I don’t know what you mean by «XDG bars», but yes, I mean configure through and environment variable. Yes, the XDG Base Directory Specification is used by neovim but the paths to these files are compiled into neovim per https://github.com/neovim/neovim/blob/master/src/nvim/os/stdpaths.c#L25-L27. Thus, it appears these paths are not modifiable at runtime.
justinmk commented May 30, 2017
MYVIMRC env var also is available. And, XDG vars are configurable. The code only applies if those vars are not defined.
johnrichardrinehart commented May 30, 2017
That’s beautiful. You’re right. The XDG variables are configurable. What about the source code indicates to me that the binary doesn’t set those environment variables to those values at runtime but, instead, checks to see if they’re defined first?
justinmk commented May 30, 2017
Not sure what you are asking. If we did not respect defined env vars there would be no purpose to having XDG support.
johnrichardrinehart commented May 30, 2017
I was of the understanding that XDG support meant that certain directory conventions were adopted. I didn’t understand that to mean that certain environmental variables are supported. So, my question was: What about the source code that I/@mhinz referenced makes it clear that environment variables can supercede the values of %LOCALAPPDATA ?
justinmk commented May 30, 2017
You could just try it.
johnrichardrinehart commented May 30, 2017
That’s what I had done in order to confirm that you were right (3 hours ago). I just wanted to know if the fact that the XDG environment variables are evaluated at run-time is made clear in the source code I referenced (i.e. that I should have already known, without testing, that these environment variables would have been checked at run-time)
justinmk commented May 30, 2017
The code that you linked is used as fallback if the variables don’t exist. It is not used if the variables do exist.