Created
May 2, 2023 20:47
-
-
Save glinesbdev/1980184c49482e526321073ab78e20ca to your computer and use it in GitHub Desktop.
NeoVim Configuration
This file contains 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
let mapleader=',' | |
let maplocalleader=',' | |
" Vundle plugin manager | |
call plug#begin('~/.local/share/nvim/site/autoload') | |
Plug 'scrooloose/nerdcommenter' | |
Plug 'vim-ruby/vim-ruby' | |
Plug 'vim-airline/vim-airline' | |
Plug 'ctrlpvim/ctrlp.vim' | |
Plug 'rmagatti/auto-session' | |
Plug 'junegunn/fzf' | |
Plug 'tpope/vim-rails' | |
Plug 'tpope/vim-endwise' | |
Plug 'tpope/vim-surround' | |
Plug 'tpope/vim-fugitive' | |
Plug 'nvim-lua/plenary.nvim' | |
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.1' } | |
Plug 'nvim-treesitter/nvim-treesitter' | |
Plug 'autozimu/LanguageClient-neovim', { | |
\ 'branch': 'next', | |
\ 'do': 'bash install.sh', | |
\ } | |
Plug 'mattn/vim-lsp-settings' | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
call plug#end() | |
" Plugin settings | |
" LSP | |
let g:LanguageClient_serverCommands = { | |
\ 'ruby': ['~/.asdf/shims/solargraph', 'stdio'], | |
\ } | |
" Ruby on Rails settings | |
filetype plugin on | |
syntax on | |
set hidden | |
" Use 2 spaces for tabs | |
set tabstop=2 | |
set shiftwidth=2 | |
set softtabstop=2 | |
set expandtab | |
" Show line numbers | |
set number | |
" Highlight search results | |
set hlsearch | |
" Enable mouse support | |
set mouse=a | |
" Enable auto-indentation | |
set autoindent | |
" Set the default file format to UTF-8 | |
set encoding=utf-8 | |
set nobackup | |
set nowritebackup | |
set signcolumn=yes | |
" Set the color scheme | |
colorscheme desert | |
" Add syntax highlighting for Ruby on Rails | |
autocmd FileType erb setlocal filetype=eruby.html | |
autocmd FileType rhtml setlocal filetype=eruby.html | |
autocmd FileType haml setlocal filetype=haml | |
autocmd FileType slim setlocal filetype=slim | |
" Custom mappings | |
" Running current test file with RSpec | |
nnoremap <leader>t :!bundle exec rspec %<cr> | |
" Leaving insert mode | |
inoremap <silent><leader>jk <ESC> | |
" Saving a file | |
nnoremap <silent><leader>w :w<cr> | |
" Remove search highlighting | |
nnoremap <silent><leader>g :nohlsearch<cr> | |
" Source config file | |
nnoremap <silent><leader>s :source ~/.config/nvim/init.vim<cr> | |
" Open config file | |
nnoremap <silent><leader>c :e ~/.config/nvim/init.vim<cr> | |
" Copy relative filepath into system clipboard | |
nnoremap <silent><leader>rp :let @+ = expand('%')<cr> | |
" Copy full filepath into system clipboard | |
nnoremap <silent><leader>rf :let @+ = expand('%:p')<cr> | |
" Copy filename into system clipboard | |
nnoremap <silent><leader>rn :let @+ = expand('%:t')<cr> | |
" Newline in normal mode | |
nnoremap <silent><leader>o o<esc>0"_D | |
nnoremap <silent><leader>O O<esc>0"_D | |
" Plugin Mappings | |
nnoremap <silent><leader>pi :PlugInstall<cr> | |
nnoremap <silent><leader>pu :PlugUpdate<cr> | |
nnoremap <silent><leader>pU :PlugUpgrade<cr> | |
" Buffer mappings | |
nnoremap <silent><leader>bd :bd<cr> | |
nnoremap <silent><leader>bn :bn<cr> | |
nnoremap <silent><leader>bp :bp<cr> | |
" Telescope mappings | |
nnoremap <leader>ff :Telescope find_files<cr> | |
nnoremap <leader>fg :Telescope live_grep<cr> | |
nnoremap <leader>fb :Telescope buffers<cr> | |
nnoremap <leader>fh :Telescope help_tags<cr> | |
" Git mappings | |
nnoremap <leader>G :G<cr> | |
nnoremap <leader>Gco :G checkout | |
" LSP mappings | |
nmap <silent><f1> <Plug>(lcn-menu) | |
nmap <silent><f2> <Plug>(lcn-rename) | |
nmap <silent><f5> <Plug>(lcn-definition) | |
nmap <silent><leader>ds <Plug>(lcn-symbols) | |
" CoC mappings | |
inoremap <silent><expr> <c-space> coc#refresh() | |
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>" | |
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() | |
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" | |
" Functions | |
" CoC functions | |
function! CheckBackspace() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment