Last active
April 19, 2025 06:16
-
-
Save Hopobcn/3972201118acd61f8584fe98a9bc446a to your computer and use it in GitHub Desktop.
neovim configuration with vim-airline, gruvbox colors & deoplete C/C++ code completion
This file contains hidden or 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
call plug#begin('~/.config/nvim/plugged') | |
" Plugins { | |
" airline is a better status line and a tab-bar for nvim. | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
" gruvbox colorscheme. Seems to work the best for me. | |
Plug 'morhetz/gruvbox' | |
" deoplete - code completion. REQUIRES: :echo has("python3") | |
if has('nvim') | |
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } | |
else | |
Plug 'Shougo/deoplete.nvim' | |
Plug 'roxma/nvim-yarp' | |
Plug 'roxma/vim-hug-neovim-rpc' | |
endif | |
" deoplete-clang - code completion for C/C++ | |
" Plug 'zchee/deoplete-clang' | |
" | |
" } | |
call plug#end() | |
if has('autocmd') | |
filetype plugin indent on | |
endif | |
if has('syntax') && !exists('g:syntax_on') | |
syntax enable | |
endif | |
" Map the leader key to , | |
let mapleader="\<SPACE>" | |
" General { | |
set smarttab | |
set noautoindent " I indent my code myself. | |
set nocindent " I indent my code myself. | |
"set smartindent " Or I let the smartindent take care of it. | |
set nrformats-=octal | |
set ttimeout | |
set ttimeoutlen=100 | |
" } | |
" Search { | |
set ignorecase " Make searching case insensitive | |
set smartcase " ... unless the query has capital letters. | |
set gdefault " Use 'g' flag by default with :s/foo/bar/. | |
set magic " Use 'magic' patterns (extended regular expressions). | |
" Use <C-L> to clear the highlighting of :set hlsearch. | |
if maparg('<C-L>', 'n') ==# '' | |
nnoremap <silent> <C-L> :nohlsearch<CR><C-L> | |
endif | |
" } | |
" Formatting { | |
set showcmd " Show (partial) command in status line. | |
set showmatch " Show matching brackets. | |
set showmode " Show current mode. | |
set ruler " Show the line and column numbers of the cursor. | |
set number " Show the line numbers on the left side. | |
"set formatoptions+=o " Continue comment marker in new lines. | |
set textwidth=0 " Hard-wrap long lines as you type them. // set this to 80~120 if required | |
set expandtab " Insert spaces when TAB is pressed. | |
set tabstop=4 " Render TABs using this many spaces. | |
set shiftwidth=4 " Indentation amount for < and > commands. | |
set noerrorbells " No beeps. | |
set modeline " Enable modeline. | |
"set esckeys " Cursor keys in insert mode. | |
set linespace=0 " Set line-spacing to minimum. | |
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J) | |
" More natural splits | |
set splitbelow " Horizontal split below current. | |
set splitright " Vertical split to right of current. | |
if !&scrolloff | |
set scrolloff=3 " Show next 3 lines while scrolling. | |
endif | |
if !&sidescrolloff | |
set sidescrolloff=5 " Show next 5 columns while side-scrolling. | |
endif | |
set display+=lastline | |
set nostartofline " Do not jump to first character with page commands. | |
" Tell Vim which characters to show for expanded TABs, | |
" trailing whitespace, and end-of-lines. VERY useful! | |
if &listchars ==# 'eol:$' | |
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+ | |
endif | |
set list " Show problematic characters. | |
" Also highlight all tabs and trailing whitespace characters. | |
highlight ExtraWhitespace ctermbg=darkgreen guibg=darkgreen | |
match ExtraWhitespace /\s\+$\|\t/ | |
" } | |
" Configuration { | |
if has('path_extra') | |
setglobal tags-=./tags tags^=./tags; | |
endif | |
set autochdir " Switch to current file's parent directory. | |
" Remove special characters for filename | |
set isfname-=: | |
set isfname-== | |
set isfname-=+ | |
" Map ; to : | |
nnoremap ; : | |
if &history < 1000 | |
set history=1000 " Number of lines in command history. | |
endif | |
if &tabpagemax < 50 | |
set tabpagemax=50 " Maximum tab pages. | |
endif | |
if &undolevels < 200 | |
set undolevels=200 " Number of undo levels. | |
endif | |
" Path/file expansion in colon-mode. | |
set wildmenu | |
set wildmode=list:longest | |
set wildchar=<TAB> | |
if !empty(&viminfo) | |
set viminfo^=! " Write a viminfo file with registers. | |
endif | |
set sessionoptions-=options | |
set nobackup " no backup files | |
set noswapfile " no swap files | |
set wildignore=*.swp,*.bak,*.pyc,*.class | |
" Allow color schemes to do bright colors without forcing bold. | |
if &t_Co == 8 && $TERM !~# '^linux' | |
set t_Co=16 | |
endif | |
" Remove trailing spaces before saving text files | |
" http://vim.wikia.com/wiki/Remove_trailing_spaces | |
" ----DISACTIVATED DUE TOO MUCH DIFF GIT DIFFERENCES ----- | |
"autocmd BufWritePre * :call StripTrailingWhitespace() | |
function! StripTrailingWhitespace() | |
if !&binary && &filetype != 'diff' | |
normal mz | |
normal Hmy | |
if &filetype == 'mail' | |
" Preserve space after e-mail signature separator | |
%s/\(^--\)\@<!\s\+$//e | |
else | |
%s/\s\+$//e | |
endif | |
normal 'yz<Enter> | |
normal `z | |
endif | |
endfunction | |
" Diff options | |
set diffopt+=iwhite | |
"Enter to go to EOF and backspace to go to start | |
nnoremap <CR> G | |
nnoremap <BS> gg | |
" Stop cursor from jumping over wrapped lines | |
nnoremap j gj | |
nnoremap k gk | |
" Make HOME and END behave like shell | |
"inoremap <C-E> <End> | |
"inoremap <C-A> <Home> | |
" Enable mouse support (move cursor with mouse) | |
set mouse=a | |
" Python configurations | |
let g:python3_host_prog = '/usr/bin/python3' | |
" } | |
" UI Options { | |
" Colorscheme options. | |
set bg=dark | |
colorscheme gruvbox | |
" Relative numbering | |
function! NumberToggle() | |
if(&relativenumber == 1) | |
set nornu | |
set number | |
else | |
set rnu | |
endif | |
endfunc | |
" Toggle between normal and relative numbering. | |
nnoremap <leader>r :call NumberToggle()<cr> | |
" Sets a status line. If in a Git repository, shows the current branch. | |
" Also shows the current file name, line and column number. | |
"if has('statusline') | |
" set laststatus=2 | |
" " Broken down into easily includeable segments | |
" set statusline=%<%f\ " Filename | |
" set statusline+=%w%h%m%r " Options | |
" "set statusline+=%{fugitive#statusline()} " Git Hotness | |
" set statusline+=\ [%{&ff}/%Y] " Filetype | |
" set statusline+=\ [%{getcwd()}] " Current dir | |
" set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info | |
"endif | |
" } | |
" Keybindings { | |
" Save file | |
nnoremap <Leader>w :w<CR> | |
"Copy and paste from system clipboard | |
vmap <Leader>y "+y | |
vmap <Leader>d "+d | |
nmap <Leader>p "+p | |
nmap <Leader>P "+P | |
vmap <Leader>p "+p | |
vmap <Leader>P "+P | |
" Move between buffers | |
nmap <Leader>l :bnext<CR> | |
nmap <Leader>h :bprevious<CR> | |
" } | |
" Experimental { | |
" Search and Replace | |
nmap <Leader>s :%s//g<Left><Left> | |
" } | |
" Plugin Settings { | |
" Airline { | |
if !exists('g:airline_symbols') | |
let g:airline_symbols = {} | |
endif | |
let g:airline#extensions#tabline#enabled = 1 | |
let g:airline#extensions#tabline#buffer_idx_mode = 1 | |
let g:airline#extensions#tabline#fnamemod = ':t' | |
let g:airline#extensions#tabline#left_sep = '' | |
let g:airline#extensions#tabline#left_alt_sep = '' | |
let g:airline#extensions#tabline#right_sep = '' | |
let g:airline#extensions#tabline#right_alt_sep = '' | |
let g:airline#extensions#tabline#formatter = 'default' | |
" unicode symbols | |
let g:airline_left_sep = '»' | |
let g:airline_left_sep = '▶' | |
let g:airline_right_sep = '«' | |
let g:airline_right_sep = '◀' | |
let g:airline_symbols.crypt = '🔒' | |
let g:airline_symbols.linenr = '␊' | |
let g:airline_symbols.linenr = '' | |
let g:airline_symbols.linenr = '¶' | |
let g:airline_symbols.maxlinenr = '☰' | |
let g:airline_symbols.maxlinenr = '' | |
let g:airline_symbols.branch = '⎇' | |
let g:airline_symbols.paste = 'ρ' | |
let g:airline_symbols.paste = 'Þ' | |
let g:airline_symbols.paste = '∥' | |
let g:airline_symbols.spell = 'Ꞩ' | |
let g:airline_symbols.notexists = '∄' | |
let g:airline_symbols.whitespace = 'Ξ' | |
" Theme ( github.com/vim-airline/vim-airline-themes | |
let g:airline_theme= 'gruvbox' | |
" } | |
" CtrlP { | |
" Open file menu | |
nnoremap <Leader>o :CtrlP<CR> | |
" Open buffer menu | |
nnoremap <Leader>b :CtrlPBuffer<CR> | |
" Open most recently used files | |
nnoremap <Leader>f :CtrlPMRUFiles<CR> | |
" } | |
" deoplete { | |
" " Use deoplete | |
" let g:deoplete#enable_at_startup = 1 | |
" } | |
" deoplete-clang { | |
" " Set default paths [REQURIED] | |
" let g:deoplete#sources#clang#libclang_path = '/usr/lib/llvm-3.8/lib/libclang.so.1' | |
" let g:deoplete#sources#clang#clang_header = '/usr/lib/clang' | |
" " Some CFLAGS/CPPFLAGS [OPTIONAL] | |
" let g:deoplete#souces#clang#std = {'c': 'c11', 'cpp': 'c++11', 'objc': 'c11', 'objcpp': 'c++1z'} | |
" } | |
" } | |
" vim:set ft=vim sw=2 ts=2: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks