365 lines
11 KiB
VimL
365 lines
11 KiB
VimL
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" CONFIGURACIÓN BÁSICA
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" Codificación
|
|
set encoding=utf-8
|
|
set fileencoding=utf-8
|
|
set fileencodings=utf-8
|
|
set fileformats=unix,dos,mac
|
|
|
|
" Arregla identación por backspace
|
|
set backspace=indent,eol,start
|
|
|
|
" Linea infinita
|
|
set nowrap
|
|
|
|
" Tabulaciones
|
|
set tabstop=4
|
|
set softtabstop=0
|
|
set shiftwidth=4
|
|
set expandtab
|
|
|
|
" Búsqueda
|
|
set hlsearch
|
|
set incsearch
|
|
set ignorecase
|
|
set smartcase
|
|
|
|
" Menú salvaje!
|
|
set wildmenu
|
|
set wildmode=list:longest,full
|
|
|
|
" Mapea la tecla líder a ,
|
|
let mapleader=','
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" CONFIGURACIÓN VISUAL
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" Sintaxis
|
|
syntax on
|
|
|
|
" Linea de estado
|
|
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
|
|
|
|
" Números de linea
|
|
set rnu
|
|
set nu
|
|
set scrolloff=8 "no haga scroll cuando faltan 4 lineas
|
|
|
|
" Marca en la columan 80
|
|
set colorcolumn=80
|
|
highlight ColorColumn ctermbg=238
|
|
|
|
" Centra el resultado de las busquedas para mejor enfoque
|
|
nnoremap n nzzzv
|
|
nnoremap N Nzzzv
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" CONFIGURACIÓN VARIOS
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" Disable visualbell
|
|
set noerrorbells visualbell t_vb=
|
|
if has('autocmd')
|
|
autocmd GUIEnter * set visualbell t_vb=
|
|
endif
|
|
|
|
"" Copy/Paste/Cut
|
|
if has('unnamedplus')
|
|
set clipboard=unnamed,unnamedplus
|
|
endif
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" VIM-PLUG CORE
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
|
|
|
|
" let g:vim_bootstrap_langs = "go,html,javascript,python"
|
|
" let g:vim_bootstrap_editor = "nvim" " nvim or vim
|
|
|
|
if !filereadable(vimplug_exists)
|
|
if !executable("curl")
|
|
echoerr "You have to install curl or first install vim-plug yourself!"
|
|
execute "q!"
|
|
endif
|
|
echo "Installing Vim-Plug..."
|
|
echo ""
|
|
silent exec "!\curl -fLo " . vimplug_exists . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
|
|
let g:not_finish_vimplug = "yes"
|
|
|
|
autocmd VimEnter * PlugInstall
|
|
endif
|
|
|
|
" Required:
|
|
call plug#begin(expand('~/.config/nvim/plugged'))
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" INSTALACIÓN DE PLUGGINS
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
call plug#begin('~/.vim/plugged') " comienzo instalación de pluggins
|
|
|
|
" Esquema de colores
|
|
Plug 'morhetz/gruvbox'
|
|
|
|
" Gestor de archivos
|
|
Plug 'scrooloose/nerdtree'
|
|
Plug 'jistr/vim-nerdtree-tabs'
|
|
|
|
" Comentar lineas
|
|
Plug 'tpope/vim-commentary'
|
|
|
|
" Neovim Tree shitter - Sintaxis highlight
|
|
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
|
|
|
" LSP (Language Server Protocol) - para autocompletar, vamos...
|
|
Plug 'neovim/nvim-lspconfig'
|
|
Plug 'williamboman/nvim-lsp-installer'
|
|
" Plug 'kabouzeid/nvim-lspinstall'
|
|
" Plug 'hrsh7th/nvim-compe'
|
|
"Plug 'nvim-lua/completion-nvim'
|
|
"Plug 'glepnir/lspsaga.nvim'
|
|
Plug 'hrsh7th/cmp-nvim-lsp'
|
|
Plug 'hrsh7th/cmp-buffer'
|
|
Plug 'hrsh7th/cmp-path'
|
|
Plug 'hrsh7th/cmp-cmdline'
|
|
Plug 'hrsh7th/nvim-cmp'
|
|
" For vsnip users.
|
|
Plug 'hrsh7th/cmp-vsnip'
|
|
Plug 'hrsh7th/vim-vsnip'
|
|
|
|
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
|
|
Plug 'junegunn/fzf.vim'
|
|
Plug 'airblade/vim-rooter'
|
|
|
|
call plug#end() " fin de la instalción de pluggins
|
|
|
|
" Configuración esquema de colores
|
|
let g:gruvbox_contrast_dark = 'hard'
|
|
if exists('+termguicolors')
|
|
let &t_8f="\<Esc>[38;2;%lu;%lu;%lum"
|
|
let &t_8b="\<Esc>[48;2;%lu;%lu;%lum"
|
|
endif
|
|
let g:gruvbox_invert_selection='0'
|
|
|
|
colorscheme gruvbox
|
|
set background=dark
|
|
|
|
" NERDTree configuration
|
|
let g:NERDTreeChDirMode=2
|
|
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
|
|
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
|
|
let g:NERDTreeShowBookmarks=1
|
|
let g:nerdtree_tabs_focus_on_files=1
|
|
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
|
|
let g:NERDTreeWinSize = 50
|
|
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
|
|
nnoremap <silent> <F2> :NERDTreeFind<CR>
|
|
nnoremap <silent> <F3> :NERDTreeToggle<CR>
|
|
|
|
" Treesitter config
|
|
lua <<EOF
|
|
require'nvim-treesitter.configs'.setup {
|
|
-- one of "all", "maintained" (parsers with maintainers), or a list of languages
|
|
ensure_installed = {
|
|
"python", "javascript", "go", "rust", "c", "html", "css"
|
|
},
|
|
indent = { enable = true },
|
|
highlight = {
|
|
enable = true,
|
|
-- disable = { "c", "rust" }, -- lista de lenguajes desactivados
|
|
},
|
|
incremental_selection = { enable = true },
|
|
textobjects = { enable = true }
|
|
|
|
}
|
|
EOF
|
|
|
|
" LSP configuracion
|
|
" set completeopt=menuone,noinsert,noselect
|
|
set completeopt=menu,menuone,noselect
|
|
let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy']
|
|
|
|
lua <<EOF
|
|
-- Setup nvim-cmp.
|
|
local cmp = require'cmp'
|
|
|
|
cmp.setup({
|
|
snippet = {
|
|
-- REQUIRED - you must specify a snippet engine
|
|
expand = function(args)
|
|
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
|
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
|
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
|
-- require'snippy'.expand_snippet(args.body) -- For `snippy` users.
|
|
end,
|
|
},
|
|
mapping = {
|
|
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
|
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
|
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
|
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
|
|
['<C-e>'] = cmp.mapping({
|
|
i = cmp.mapping.abort(),
|
|
c = cmp.mapping.close(),
|
|
}),
|
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
|
},
|
|
sources = cmp.config.sources({
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'vsnip' }, -- For vsnip users.
|
|
-- { name = 'luasnip' }, -- For luasnip users.
|
|
-- { name = 'ultisnips' }, -- For ultisnips users.
|
|
-- { name = 'snippy' }, -- For snippy users.
|
|
}, {
|
|
{ name = 'buffer' },
|
|
})
|
|
})
|
|
|
|
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
|
cmp.setup.cmdline('/', {
|
|
sources = {
|
|
{ name = 'buffer' }
|
|
}
|
|
})
|
|
|
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
|
cmp.setup.cmdline(':', {
|
|
sources = cmp.config.sources({
|
|
{ name = 'path' }
|
|
}, {
|
|
{ name = 'cmdline' }
|
|
})
|
|
})
|
|
|
|
-- setup lsp installer
|
|
local lsp_installer = require("nvim-lsp-installer")
|
|
|
|
-- Register a handler that will be called for all installed servers.
|
|
-- Alternatively, you may also register handlers on specific server instances instead (see example below).
|
|
lsp_installer.on_server_ready(function(server)
|
|
local opts = {}
|
|
|
|
-- (optional) Customize the options passed to the server
|
|
-- if server.name == "tsserver" then
|
|
-- opts.root_dir = function() ... end
|
|
-- end
|
|
|
|
-- setup lspconfig
|
|
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
|
opts.capabilities = capabilities
|
|
|
|
-- This setup() function is exactly the same as lspconfig's setup function.
|
|
-- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
|
server:setup(opts)
|
|
end)
|
|
EOF
|
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" Mapeos
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" Limpia busqueda
|
|
nnoremap <silent> <leader><space> :noh<cr>
|
|
|
|
" Pestañas
|
|
nnoremap <Tab> gt
|
|
nnoremap <S-Tab> gT
|
|
nnoremap <silent> <S-t> :tabnew<CR>
|
|
|
|
" Retabular
|
|
nnoremap <silent> <leader>g gg=G
|
|
|
|
" Mover bloques en modo visual
|
|
vnoremap J :m '>+1<CR>gv=gv
|
|
vnoremap K :m '<-2<CR>gv=gv
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" POR HACER
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" lsp - Instalar servidores de lenguaje
|
|
" :LspInstall go
|
|
" :LspInstall python
|
|
"
|
|
" linter
|
|
"
|
|
" sistema para buscar: telescope, harpoon, fuzzyfinder, grep...
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" FZF Config
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" https://www.chrisatmachine.com/Neovim/08-fzf/
|
|
" Dependencias: fzf ripgrep universal-ctags silversearcher-ag fd
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
" This is the default extra key bindings
|
|
let g:fzf_action = {
|
|
\ 'ctrl-t': 'tab split',
|
|
\ 'ctrl-x': 'split',
|
|
\ 'ctrl-v': 'vsplit' }
|
|
|
|
" Enable per-command history.
|
|
" CTRL-N and CTRL-P will be automatically bound to next-history and
|
|
" previous-history instead of down and up. If you don't like the change,
|
|
" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS.
|
|
let g:fzf_history_dir = '~/.local/share/fzf-history'
|
|
|
|
nnoremap <leader>ff :Files<CR>
|
|
nnoremap <leader>fb :Buffers<CR>
|
|
nnoremap <leader>fg :Rg<CR>
|
|
nnoremap <leader>ft :Tags<CR>
|
|
nnoremap <leader>fm :Marks<CR>
|
|
|
|
let g:fzf_tags_command = 'ctags -R'
|
|
" Border color
|
|
let g:fzf_layout = {'up':'~90%', 'window': { 'width': 0.8, 'height': 0.8,'yoffset':0.5,'xoffset': 0.5, 'highlight': 'Todo', 'border': 'sharp' } }
|
|
|
|
let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline'
|
|
let $FZF_DEFAULT_COMMAND="rg --files --hidden"
|
|
|
|
|
|
" Customize fzf colors to match your color scheme
|
|
let g:fzf_colors =
|
|
\ { 'fg': ['fg', 'Normal'],
|
|
\ 'bg': ['bg', 'Normal'],
|
|
\ 'hl': ['fg', 'Comment'],
|
|
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
|
|
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
|
|
\ 'hl+': ['fg', 'Statement'],
|
|
\ 'info': ['fg', 'PreProc'],
|
|
\ 'border': ['fg', 'Ignore'],
|
|
\ 'prompt': ['fg', 'Conditional'],
|
|
\ 'pointer': ['fg', 'Exception'],
|
|
\ 'marker': ['fg', 'Keyword'],
|
|
\ 'spinner': ['fg', 'Label'],
|
|
\ 'header': ['fg', 'Comment'] }
|
|
|
|
"Get Files
|
|
command! -bang -nargs=? -complete=dir Files
|
|
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), <bang>0)
|
|
|
|
|
|
" Get text in files with Rg
|
|
command! -bang -nargs=* Rg
|
|
\ call fzf#vim#grep(
|
|
\ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
|
|
\ fzf#vim#with_preview(), <bang>0)
|
|
|
|
" Ripgrep advanced
|
|
function! RipgrepFzf(query, fullscreen)
|
|
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true'
|
|
let initial_command = printf(command_fmt, shellescape(a:query))
|
|
let reload_command = printf(command_fmt, '{q}')
|
|
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
|
|
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
|
|
endfunction
|
|
|
|
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
|
|
|
|
" Git grep
|
|
command! -bang -nargs=* GGrep
|
|
\ call fzf#vim#grep(
|
|
\ 'git grep --line-number '.shellescape(<q-args>), 0,
|
|
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
|
|
|