Last active
July 27, 2024 14:08
-
-
Save Aneureka/8eaee248f97da207da3906ef45e52cea to your computer and use it in GitHub Desktop.
My new neovim configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace vim with neo vim | |
if type nvim > /dev/null 2>&1; then | |
alias vim='nvim' | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ================ | |
" Migrate from vim | |
" ---------------- | |
set runtimepath^=~/.vim runtimepath+=~/.vim/after | |
let &packpath = $runtimepath | |
source ~/.vimrc | |
" ==================== | |
" Basic configurations | |
" -------------------- | |
set nocompatible | |
syntax on | |
filetype on | |
filetype indent on | |
filetype plugin on | |
set number | |
set hidden | |
set ignorecase | |
set smartcase | |
set incsearch | |
set noerrorbells visualbell t_vb= | |
set mouse+=a | |
set encoding=utf-8 | |
set tabstop=2 softtabstop=2 shiftwidth=2 expandtab smarttab | |
set expandtab | |
set list listchars=tab:►\ ,trail:· | |
set scrolloff=5 | |
set tw=0 | |
set indentexpr= | |
set backspace=indent,eol,start | |
set foldmethod=indent | |
set foldlevel=99 | |
set laststatus=2 | |
set autochdir | |
set cursorline | |
" ============ | |
" Key mappings | |
" ------------ | |
let mapleader=' ' | |
nmap n nzz | |
nmap N Nzz | |
nmap S :w<Return> | |
nmap Q :q<Return> | |
" Tabs | |
nmap te :tabedit | |
nmap <S-Tab> :tabprev<Return> | |
nmap <Tab> :tabnext<Return> | |
" Windows | |
nmap ss :split<Return><C-w>w | |
nmap sv :vsplit<Return><C-w>w | |
nmap <Space> <C-w>w | |
map sq <C-w>q | |
map sh <C-w>h | |
map sk <C-w>k | |
map sj <C-w>j | |
map sl <C-w>l | |
map s<left> <C-w>5< | |
map s<right> <C-w>5> | |
map s<up> <C-w>5+ | |
map s<down> <C-w>- | |
" ======= | |
" Plugins | |
" ------- | |
call plug#begin() | |
Plug 'neovim/nvim-lspconfig' | |
Plug 'hrsh7th/cmp-nvim-lsp' | |
Plug 'hrsh7th/cmp-buffer' | |
Plug 'hrsh7th/cmp-path' | |
Plug 'hrsh7th/cmp-cmdline' | |
Plug 'hrsh7th/nvim-cmp' | |
Plug 'hrsh7th/vim-vsnip' | |
Plug 'hrsh7th/vim-vsnip-integ' | |
Plug 'machakann/vim-sandwich' | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
Plug 'onsails/lspkind.nvim' | |
Plug 'jiangmiao/auto-pairs' | |
Plug 'kevinhwang91/nvim-hlslens' | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
Plug 'junegunn/fzf.vim' | |
Plug 'junegunn/vim-easy-align' | |
Plug 'akinsho/toggleterm.nvim', {'tag' : 'v1.*'} | |
Plug 'justinmk/vim-sneak' | |
Plug 'RRethy/vim-illuminate' | |
call plug#end() | |
" FZF config | |
nmap <Leader>f :Files<Enter> | |
" Align config | |
xmap ga <Plug>(EasyAlign) | |
nmap ga <Plug>(EasyAlign) | |
" Terminal | |
:lua require("toggleterm").setup{} | |
autocmd TermEnter term://*toggleterm#* | |
\ tnoremap <silent><c-t> <Cmd>exe v:count1 . "ToggleTerm"<CR> | |
nnoremap <silent><c-t> <Cmd>exe v:count1 . "ToggleTerm"<CR> | |
inoremap <silent><c-t> <Esc><Cmd>exe v:count1 . "ToggleTerm"<CR> | |
" Sneak | |
map f <Plug>Sneak_s | |
map F <Plug>Sneak_S | |
" LSP config | |
nmap <silent> ff <cmd>lua vim.lsp.buf.format { async = true }<CR> | |
:lua require'lspconfig'.clangd.setup{} | |
" CMP config | |
set completeopt=menu,menuone,noselect | |
lua <<EOF | |
-- Setup nvim-cmp. | |
local cmp = require('cmp') | |
local lspkind = require('lspkind') | |
cmp.setup({ | |
snippet = { | |
expand = function(args) | |
vim.fn["vsnip#anonymous"](args.body) | |
end, | |
}, | |
mapping = cmp.mapping.preset.insert({ | |
['<Tab>'] = function(fallback) | |
if cmp.visible() then | |
cmp.select_next_item() | |
else | |
fallback() | |
end | |
end, | |
['<S-Tab>'] = function(fallback) | |
if cmp.visible() then | |
cmp.select_prev_item() | |
else | |
fallback() | |
end | |
end, | |
['<CR>'] = cmp.mapping.confirm({ select = true }), | |
['<C-e>'] = cmp.mapping.abort(), | |
['<Esc>'] = cmp.mapping.close(), | |
}), | |
sources = cmp.config.sources({ | |
{ name = 'nvim_lsp' }, | |
}, { | |
{ name = 'buffer' }, | |
}), | |
formatting = { | |
format = lspkind.cmp_format({ | |
mode = "symbol_text", | |
menu = ({ | |
nvim_lsp = "[LSP]", | |
ultisnips = "[US]", | |
nvim_lua = "[Lua]", | |
path = "[Path]", | |
buffer = "[Buffer]", | |
emoji = "[Emoji]", | |
omni = "[Omni]", | |
}), | |
}), | |
}, | |
}) | |
-- Use buffer source for `/` | |
cmp.setup.cmdline('/', { | |
mapping = cmp.mapping.preset.cmdline(), | |
sources = { | |
{ name = 'buffer' } | |
} | |
}) | |
-- Use cmdline & path source for ':' | |
cmp.setup.cmdline(':', { | |
mapping = cmp.mapping.preset.cmdline(), | |
sources = cmp.config.sources({ | |
{ name = 'path' } | |
}, { | |
{ name = 'cmdline' } | |
}) | |
}) | |
-- Setup lspconfig. | |
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) | |
require('lspconfig')['clangd'].setup { | |
capabilities = capabilities | |
} | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
filetype plugin indent on
is duplicated withfiletype indent on
+filetype plugin on