Neovim is a refactor, and sometimes redactor, in the tradition of Vim (which itself derives from Stevie). It is not a rewrite but a continuation and extension of Vim. Many clones and derivatives exist, some very cleverβbut none are Vim. Neovim is built for users who want the good parts of Vim, and more.
Goals
- Enable new contributors, remove barriers to entry.
- Unblock plugin authors.
- Develop first-class Lua/LuaJIT scripting alternative to VimL.
- Target all platforms supported by libuv.
- Leverage ongoing Vim development.
- Optimize out of the box, for new users but especially regular users.
- Deliver consistent cross-platform experience.
- In matters of taste/ambiguity, favor tradition/compatibility...
- ...but prefer usability if the benefits are extreme.
Non-goals
- Turn Vim into an IDE
- Limit third-party applications (such as IDEs!) built with Neovim
- Deprecate VimL
- POSIX vi-compatibility
Install
sudo apt install neovim
Packer
git clone --depth 1 https://github.com/wbthomason/packer.nvim\
~/.local/share/nvim/site/pack/packer/start/packer.nvim
Settings
mkdir -p ~/.config/nvim/lua/configs
mkdir -p ~/.config/nvim/lua/plugins
nvim ~/.config/nvim/init.lua
require('configs.settings')
require('configs.keymaps')
require('plugins.plugins')
require('plugins.style')
require('plugins.telescope')
require('plugins.lsp')
nvim ~/.config/nvim/lua/configs/settings.lua
vim.cmd[[ syntax on ]]
vim.cmd[[ filetype plugin on ]]
vim.cmd[[ set encoding=UTF-8 ]]
vim.cmd[[ set textwidth=101 ]]
vim.cmd[[ set tabstop=4 ]]
vim.cmd[[ set shiftwidth=2 smarttab ]]
vim.cmd[[ set softtabstop=0 ]]
vim.cmd[[ set autoindent ]]
vim.cmd[[ set expandtab ]]
vim.cmd[[ set smarttab ]]
vim.cmd[[ set laststatus=4 ]]
vim.cmd[[ set ignorecase ]]
vim.cmd[[ set t_Co=256 ]]
vim.cmd[[ set noshowmode ]]
vim.cmd[[ set hlsearch ]]
vim.cmd[[ set hidden ]]
vim.cmd[[ set nobuflisted ]]
vim.cmd[[ set nu! ]]
vim.cmd[[ set termguicolors ]]
nvim ~/.config/nvim/lua/configs/keymaps.lua
vim.cmd[[ nmap <C-t> :Telescope<CR> ]]
nvim ~/.config/nvim/lua/plugins/plugins.lua
vim.cmd [[ packadd packer.nvim ]]
return require('packer').startup(function()
-- Packer
use 'wbthomason/packer.nvim'
-- Style
use 'navarasu/onedark.nvim'
use {
'nvim-lualine/lualine.nvim',
requires = {
'kyazdani42/nvim-web-devicons',
opt = true
}
}
use 'lukas-reineke/indent-blankline.nvim'
use 'norcalli/nvim-colorizer.lua'
-- Autopairs
use 'tpope/vim-surround'
use 'windwp/nvim-autopairs'
-- LPS
use 'neovim/nvim-lspconfig'
use 'hrsh7th/nvim-cmp'
use 'hrsh7th/cmp-nvim-lsp'
use 'hrsh7th/cmp-buffer'
use 'hrsh7th/cmp-path'
use 'hrsh7th/cmp-cmdline'
use 'saadparwaiz1/cmp_luasnip'
use 'L3MON4D3/LuaSnip'
use 'rafamadriz/friendly-snippets'
use 'ray-x/lsp_signature.nvim'
use 'onsails/lspkind-nvim'
-- Telescope
use { 'nvim-telescope/telescope.nvim', tag = '0.1.0' }
use 'nvim-lua/plenary.nvim'
use 'BurntSushi/ripgrep'
use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }
use 'sharkdp/fd'
use 'nvim-treesitter/nvim-treesitter'
if PACKER_BOOTSTRAP then
require("packer").sync()
end
end)
nvim ~/.config/nvim/lua/plugins/style.lua
require('onedark').setup{
style = 'darker',
transparent = true
}
require('onedark').load()
require('lualine').setup{
options = {
theme = 'onedark'
}
}
require('lualine').get_config()
vim.opt.listchars:append("space:β
")
vim.cmd [[highlight IndentBlanklineIndent1 guifg=#E06C75 gui=nocombine]]
vim.cmd [[highlight IndentBlanklineIndent2 guifg=#E5C07B gui=nocombine]]
vim.cmd [[highlight IndentBlanklineIndent3 guifg=#98C379 gui=nocombine]]
vim.cmd [[highlight IndentBlanklineIndent4 guifg=#56B6C2 gui=nocombine]]
vim.cmd [[highlight IndentBlanklineIndent5 guifg=#61AFEF gui=nocombine]]
vim.cmd [[highlight IndentBlanklineIndent6 guifg=#C678DD gui=nocombine]]
vim.cmd([[
hi! MatchParen cterm=NONE,bold gui=NONE,bold guibg=NONE guifg=#FFFFFF
let g:indentLine_fileTypeExclude = ['dashboard']
]])
require("indent_blankline").setup {
show_end_of_line = true,
space_char_blankline = " ",
char_highlight_list = {
"IndentBlanklineIndent1",
"IndentBlanklineIndent2",
"IndentBlanklineIndent3",
"IndentBlanklineIndent4",
"IndentBlanklineIndent5",
"IndentBlanklineIndent6",
},
}
require'colorizer'.setup()
require('nvim-autopairs').setup({
enable_check_bracket_line = false
})
nvim ~/.config/nvim/lua/plugins/telescope.lua
require'nvim-treesitter.configs'.setup {
ensure_installed = { 'python', 'go', 'javascript', 'help' },
sync_install = false,
auto_install = true,
indent = {
enable = true
}
}
nvim ~/.config/nvim/lua/plugins/lsp.lua
local has_any_words_before = function()
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then
return false
end
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
require'lspconfig'.clangd.setup{}
require "lsp_signature".setup()
vim.o.completeopt = 'menuone,noselect'
local cmp = require'cmp'
local luasnip = require("luasnip")
local lspkind = require('lspkind')
local source_mapping = {
buffer = "β Buffer",
nvim_lsp = "π LSP",
nvim_lua = "π Lua",
cmp_tabnine = "π‘ Tabnine",
path = "π§ Path",
luasnip = "π LuaSnip"
}
cmp.setup({
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'nvim_lua' },
},
formatting = {
format = function(entry, vim_item)
vim_item.kind = lspkind.presets.default[vim_item.kind]
local menu = source_mapping[entry.source.name]
if entry.source.name == 'cmp_tabnine' then
if entry.completion_item.data ~= nil and entry.completion_item.data.detail ~= nil then
menu = entry.completion_item.data.detail .. ' ' .. menu
end
vim_item.kind = 'ο§'
end
vim_item.menu = menu
return vim_item
end
},
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = {
['<C-n>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
['<Down>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
['<Up>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
['<Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), '')
else
fallback()
end
end,
['<S-Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-jump-prev', true, true, true), '')
else
fallback()
end
end,
},
})
Compile
:PackerSync
:LspInstall <lang>
:TSInstall <lang>