Neovim configuration
- On Path
~
, exec commandgit clone --depth 1 https://github.com/wbthomason/packer.nvim\ ~/.local/share/nvim/site/pack/packer/start/packer.nvim
to install packer.nvim - Go to vim to exec
:w
:PackerSync
:luafile %
ensure that you use nerd-font in terminal
- install
brew tap homebrew/cask-fonts
brew install --cask font-hack-nerd-font
- iterm font switch to 'Hack Nerd Font Mono'
If you use mac, <A-.> means <ESC-.>. And you shoud hold key for a while.
ensure fd(replace find command) & ripgrep(replace grep command) has installed.
brew install fd
brew install ripgrep
use nvim-lsp-installer instead.
after install nvim-lspconfig plugin, ensure use right node version.
1. check current node version.
nvm version
nvm default [version>15]
nvm use [version>15]
2. install language server e.g. pyright
npm i -g pyright
3. load configuration
see github -> https://github.com/neovim/nvim-lspconfig
4. open a py file to check Lsp is installed successfully
input :LspInfo
You can usc nvim-lsp-installer to install certain language server, which has already support formatting.
To run built-in sources, the command specified below must be available on your $PATH and visible to Neovim. For example, to check if stylua is available, run the following (Vim, not Lua) command:
" should echo 1 if available (and 0 if not)
:echo executable("stylua")
if not, you can use homebrew to install.
e.g.
brew install stylua
There's two details you should notice.
- set certain language server
require("mason-lspconfig").setup({
ensure_installed = {
"lua_ls",
"bashls",
"emmet_ls",
"pyright",
"clangd",
"kotlin_language_server",
"jdtls",
},
})
- read mason-lspconfig help documentation to bind key in certain server
require("mason-lspconfig").setup_handlers({
function(server_name)
require("lspconfig")[server_name].setup({
on_attach = common_on_attach,
})
end,
})
Pay attention to keymap filetype code.
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown",
group = vim.api.nvim_create_augroup("MarkdownSnippet", { clear = true }),
callback = function()
end,
})
Do not remap '[c' & ']c', beacause it's default git navigation key in nvim