Skip to content

Instantly share code, notes, and snippets.

@ErickAgrazal
Last active October 22, 2022 18:47
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 ErickAgrazal/fea8473535e5ebfa63a7c45f67d468c6 to your computer and use it in GitHub Desktop.
Save ErickAgrazal/fea8473535e5ebfa63a7c45f67d468c6 to your computer and use it in GitHub Desktop.
NeoVim Configuration
{
"suggest.autoTrigger": "always",
"coc.preferences.formatOnType": false,
"coc.preferences.jumpCommand": "edit",
"coc.preferences.rootPatterns": [
".vim",
".git",
".hg",
".projections.json"
],
"javascript.suggest.autoImports": true,
"javascript.suggest.paths": true
}
" Located in ~/.config/nvim/init.vim
" configuration varibles =======
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set textwidth=140
set number
set nowrap
set autoread
set background=dark
set nocompatible
set number relativenumber
" For CoC =====================
set updatetime=300
set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: There's always complete item selected by default, you may want to enable
" no select by `"suggest.noselect": true` in your configuration file.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" 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)
" Use K to show documentation in preview window.
nnoremap <silent> K :call ShowDocumentation()<CR>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
endif
endfunction
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
" =============================
if has('unix')
if has('mac') " osx
let g:python3_host_prog = '/opt/homebrew/bin/python3'
else " linux, bsd, etc
let g:python3_host_prog = '/usr/bin/python3'
endif
endif
" ==============================
" Plugin installers ============
" Automatic installation of vim plug
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Install vim-plug if not found
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
endif
" Run PlugInstall if there are missing plugins
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
\| PlugInstall --sync | source $MYVIMRC
\| endif
call plug#begin('~/.config/nvim/plugins')
" Search files
Plug 'junegunn/fzf.vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
" Intellisense
Plug 'dense-analysis/ale'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
" Search
Plug 'preservim/nerdtree'
" Themes
Plug 'dracula/vim', { 'as': 'dracula' }
" For git
Plug 'nvim-lualine/lualine.nvim'
Plug 'kyazdani42/nvim-web-devicons'
Plug 'voldikss/vim-floaterm'
" For CoC
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Keeps the function name on top of the buffer
Plug 'nvim-treesitter/nvim-treesitter'
Plug 'nvim-treesitter/nvim-treesitter-context'
call plug#end()
" =============================
" Color schemes ================
colorscheme dracula
" ==============================
"Plugin simple configurations ==
let g:deoplete#enable_at_startup = 1
let g:ale_echo_msg_format = '%linter%: %s'
let g:ale_fix_on_save = 1
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['eslint'],
\ 'vue': ['eslint'],
\}
" ==============================
" Map configurations ===========
let mapleader = " "
nmap <Leader>rg :Rg<CR>
nmap <Leader>qi :q!<CR>
nmap <Leader>x :x<CR>
nmap <Leader>qa :qall!<CR>
nmap <Leader>nt :NERDTree<CR>
nmap <Leader>tn :tabnew<CR>
nmap <Leader>sh :shell<CR>
nmap <Leader>tr :term<CR>
nnoremap <C-t> :NERDTreeFind<CR>
nnoremap <C-f> :Lines<CR>
nnoremap <C-g> :GFiles?<CR>
nnoremap <C-p> :Rg<CR>
nnoremap <C-n> :tabnew<CR>
nnoremap <C-s> :w<CR>
nnoremap <C-r> :tabdo e<CR>
" ==============================
" Initializing git status line
lua << END
require('lualine').setup()
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment