Skip to content

Instantly share code, notes, and snippets.

@joseaquino
Last active February 4, 2021 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joseaquino/3aeb9743d4fb9700751aead16e4d56fa to your computer and use it in GitHub Desktop.
Save joseaquino/3aeb9743d4fb9700751aead16e4d56fa to your computer and use it in GitHub Desktop.
Neovim configuration file
" ================
" - Plugins List -
" ================
call plug#begin('~/.config/nvim/plugged')
Plug 'tpope/vim-surround' " Select/alter block characters like {, [ and '
Plug 'junegunn/vim-easy-align' " Text alignment tool
Plug 'scrooloose/nerdtree' " Vim File manager
Plug 'itchyny/lightline.vim' " Extended status bar at bottom of editor
Plug 'sheerun/vim-polyglot' " Language syntax support
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " Fuzzy file finder
Plug 'junegunn/fzf.vim' " Fuzzy Finder additional functionalities
Plug 'dracula/vim' " Dracula color theme
Plug 'danilo-augusto/vim-afterglow' " Afterglow color theme
Plug 'drewtempelmeyer/palenight.vim' " Palenight color theme
Plug 'dyng/ctrlsf.vim' " File searching plugin
Plug 'dense-analysis/ale' " Asynchronous Lint Engine (JSLint)
Plug 'neoclide/coc.nvim', {'branch': 'release'} " Autocomplete engine
Plug 'ryanoasis/vim-devicons' " GUI file icons
Plug 'psliwka/vim-smoothie' " This (neo)vim plugin makes scrolling nice and smooth
Plug 'mattn/emmet-vim' " Provides support for expanding abbreviations similar to emmet
Plug 'mhinz/vim-startify' " This plugin provides a start screen for Vim and Neovim
Plug 'styled-components/vim-styled-components', { 'branch': 'main' } " Syntax highlighting for React styled components
Plug 'easymotion/vim-easymotion' " Provide a much simpler way to use some motions in Vim
Plug 'justinmk/vim-sneak' " Jump to any location specified by two characters
Plug 'editorconfig/editorconfig-vim' " This is an EditorConfig plugin for Vim.
Plug 'nathanaelkane/vim-indent-guides' " Indent Guides is a plugin for visually displaying indent levels in Vim.
Plug 'rust-lang/rust.vim' " Rust language syntax management plugin
Plug 'phanviet/vim-monokai-pro' " Vim Color Theme
Plug 'pantharshit00/vim-prisma' " Prisma syntax highlighting
Plug 'jxnblk/vim-mdx-js' " MDX filetype syntax highlighting
Plug 'tpope/vim-fugitive' " Git integration with Neovim
call plug#end()
" ================
" - GUI Settings -
" ================
syntax on " Turn ON syntax highlighting
filetype plugin indent on " Automatically detect file types
set number " Show line numbers on the side
set tabstop=2 softtabstop=0 expandtab shiftwidth=2 " Tabs spacing configuration
set linespace=1 " Line spacing
"set mouse=a " Allow use of the mouse in the terminal
set mouse=
"set colorcolumn=80 " Show colored column to indicate recommended max line width
set cursorline " Highlight the line where the cursor is currently located
set background=dark " Editor color scheme
colorscheme monokai_pro " Color theme of editor
set title " Set the terminal title
set list listchars=tab:»\ ,trail:·,space:· " Set to show invisibles (tabs & trailing spaces) & their highlight color
set backspace=indent,eol,start " Makes backspace key more powerful
set encoding=utf-8 " Set default encoding to UTF-8
set relativenumber " Relative numberin in the gutter line number
" Enabling true color in the editor if available
if (has("nvim"))
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
if (has("termguicolors"))
set termguicolors
endif
" Creat and load views for buffers to preserve the manual foldings
"autocmd BufWinLeave *.* mkview
"autocmd BufWinEnter *.* silent! loadview
" Remove the background color because tmux and Hyper dont show it
"hi Normal guibg=NONE ctermbg=NONE
hi CursorLine guibg=darkblue guifg=fg
" =======================
" - Custom Key Mappings -
" =======================
" leader key mapping
let mapleader = ','
" Mapping to edit file in current window with relative path expanded
map <leader>ew :e %%
" Mapping to edit file in split window with relative path expanded
map <leader>es :sp %%
" Mapping to edit file in vertical split window with relative path expanded
map <leader>ev :vsp %%
" Mapping to edit file in new tab with relative path expanded
map <leader>et :tabe %%
" Clear the search highlighting
nmap <leader>kk :noh<cr>
" Edit file using fuzzy finder
nnoremap <C-p> :<C-u>Files<CR>
" Jump definition of value under cursor
nmap <leader>jd :ALEGoToDefinition<CR>
" ===================
" - Plugins Options -
" ===================
" ----------------
" - junegunn/fzf -
" ----------------
let g:fzf_layout = { 'up': '~30%' }
let $FZF_DEFAULT_COMMAND = 'rg --files'
" -----------------------------------
" - nathanaelkane/vim-indent-guides -
" -----------------------------------
let g:indent_guides_guide_size = 1
" -----------------------
" - scrooloose/nerdtree -
" -----------------------
" Key map to toggle the NERDTree window
map <C-n> :NERDTreeToggle<CR>
" ---------------------------
" - 'itchyny/lightline.vim' -
" ---------------------------
let g:lightline = {
\ 'colorscheme': 'palenight',
\ 'component_function': {
\ 'filename': 'LightlineFilename',
\ }
\}
" Get absolute path of opened file but when inside a Git repository show path
" relative to the root of the project.
function! LightlineFilename()
let root = fnamemodify(get(b:, 'git_dir'), ':h')
let path = expand('%:p')
if path[:len(root)-1] ==# root
return path[len(root)+1:]
endif
return expand('%')
endfunction
" ------------------------
" - 'dense-analysis/ale' -
" ------------------------
let b:ale_linters = ['eslint']
let g:ale_fix_on_save = 1
" ------------------------
" - 'neoclide/coc.nvim' -
" ------------------------
let g:coc_global_extensions = [
\ 'coc-pairs',
\ 'coc-json',
\ 'coc-tsserver',
\ 'coc-css',
\ 'coc-html',
\ 'coc-emmet',
\ 'coc-phpls',
\ 'coc-tailwindcss',
\ 'coc-prettier',
\ 'coc-styled-components',
\ 'coc-tabnine'
\ ]
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
" Maps the enter key to select the autocomplete option
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Maps the Shift Tab key to the previous command of the autocomplete
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocActionAsync('doHover')
endif
endfunction
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
"" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Creates the command `:Prettier` that with run the prettier formatting on the
" document using the coc-prettier plugin
command! -nargs=0 Prettier :CocCommand prettier.formatFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment