Skip to content

Instantly share code, notes, and snippets.

@amc1981
Last active August 2, 2023 18:12
Show Gist options
  • Save amc1981/5641e9a794f07334fd6f144611c5042a to your computer and use it in GitHub Desktop.
Save amc1981/5641e9a794f07334fd6f144611c5042a to your computer and use it in GitHub Desktop.
My .vimrc configuration
" Plugins gestionados con `plug`
call plug#begin('~/.vim/autoload')
Plug 'rakr/vim-one'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'preservim/nerdtree'
Plug 'christoomey/vim-tmux-navigator'
Plug 'jiangmiao/auto-pairs'
Plug 'tpope/vim-commentary'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
call plug#end()
" Config para Themes
" vim-one
colorscheme one
" set background=light
set background=dark
" Config para Airline
let g:airline#extensions#tabline#enabled = 1 " Hace que aprezca el nombre del fichero en la parte superior izquierda
" let g:airline_theme='onedark'
let g:airline_theme='one'
" Config NERDTree
nnoremap <C-n> :NERDTreeToggle<CR>
" Configuraciones nativas
set number
set rnu
set cursorline
set mouse=a
set clipboard=unnamed
set laststatus=2
set showcmd
set noshowmode
set showmatch
set encoding=utf-8
syntax enable
" Comandos personalizados / Mapeos
" nmap: Mapeo de comandos en modo Normal
" nnoremap: Mapeo de comandos en modo Normal y ademas impide que se
" sobreescriba este mapeo
" imap: Mapeo de comandos en modo Interactivo
" vmap: Mapeo de comandos en modo Visual
nmap <C-s> :w<CR>
nmap <C-m> :x<CR>
nmap <C-w> :q!<CR>
nmap - dd
nnoremap <C-p> :bprev<CR>
nnoremap <C-o> :bnext<CR>
" AutoCommands
autocmd BufWrite *.html :CocCommand prettier.formatFile " formateamos todos los ficheros .html antes de salir
autocmd BufWrite *.js :CocCommand prettier.formatFile " formateamos todos los ficheros .js antes de salir
autocmd BufWrite *.ts :CocCommand prettier.formatFile " formateamos todos los ficheros .ts antes de salir
autocmd BufWrite *.css :CocCommand prettier.formatFile " formateamos todos los ficheros .css antes de salir
autocmd BufWrite *.scss :CocCommand prettier.formatFile " formateamos todos los ficheros .scss antes de salir
autocmd BufWrite *.md :CocCommand prettier.formatFile " formateamos todos los ficheros .md antes de salir
autocmd BufWrite *.py :CocCommand prettier.formatFile " formateamos todos los ficheros .py antes de salir
" Sustituciones iab
" Añadir al final de los enlaces en markdown, para abrirlos en nuevas pestañas del navegador.
iab _tb {:target="_blank"}
" Añadir bajo imágenes/bloques de código como texto explicativo de los mismos.
iab _fg {:.figcaption}
" Añadir al inicio de los posts para incorporar la tabla de contenidos (nativo del tema hydejack de Jekyll).
iab _tc {:.toc}

How to use

For setting up properly you have to take advice on these instructions.

Clone and link to the .vimrc file

  1. git clone this gist on your $HOME directory : git clone https://gist.github.com/amc1981/5641e9a794f07334fd6f144611c5042a.
  2. Change the name of the new folder to another more legible: mv 5641e9a794f07334fd6f144611c5042a gist-vimrc.
  3. Create a symbolic link from your $HOME to the .vimrc file: ln -s $HOME/gist-vimrc/.vimrc $HOME/.vimrc

Install plug

Now we need to activate de plugins. But first we have to install plug. Out plugins manager for vim.

  • Execute this curl command:
~ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

The expected output seems like that:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 83127  100 83127    0     0  83905      0 --:--:-- --:--:-- --:--:-- 84392
  • Enter inside your .vimrc file and execute this in Command Mode
:PlugInstall

Install Language servers vía CocInstall

For correct use of neoclide/coc.nvim plugin we need to instal nodejs on our system and run this command inside our .vimrc in Command Mode:

:CocInstall coc-json coc-tsserver coc-prettier coc-emmet coc-pyright coc-markdownlint coc-css coc-sh

With this execution, we will activate highlighting syntax for the next programming and markup languages: json, typscript, html, python, markdown, css and bash.

Some last considerations

Select any theme of your interest. If onedark seems incompatible with your Screen configuration comment this line on the .vimrc file.

" colorscheme onedark

Here, you can find a list of vim themes try them out, select one of them and configure it on your own .vimrc.

Maybe this Gist is useful for you. If you have a GitHub account you can fork this Gist and make your own modifications and improvements. An advantage of forking is that you can make changes and track them like in a GitHub repo as you can see here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment