Skip to content

Instantly share code, notes, and snippets.

@mrv1k
Created August 18, 2021 17:16
Show Gist options
  • Save mrv1k/54c9b67e3358f99cc29f305cb394a2b0 to your computer and use it in GitHub Desktop.
Save mrv1k/54c9b67e3358f99cc29f305cb394a2b0 to your computer and use it in GitHub Desktop.
wip backups of my nvim config
" set path+=**
" Nice menu when typing `:find *.py`
" set wildmode=longest,list,full
" set wildmenu
set wildmenu " Show list instead of just completing
set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all.
" Ignore files
set wildignore+=*.pyc
set wildignore+=*_build/*
set wildignore+=**/coverage/*
set wildignore+=**/node_modules/*
set wildignore+=**/android/*
set wildignore+=**/ios/*
set wildignore+=**/.git/*
set spell " Spell checking on
set scrolloff=10
set number
set relativenumber
set tabstop=4 softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set hidden
set noerrorbells
set nowrap
set colorcolumn=80
set signcolumn=yes
set splitright " Puts new vsplit windows to the right of the current
set splitbelow " Puts new split windows to the bottom of the current
" search config
set incsearch " Find as you type search
set hlsearch " Highlight search terms
set ignorecase " Case insensitive search
set smartcase " Case sensitive when uc present
" Use persistent history.
set noswapfile
set nobackup
if !isdirectory("/tmp/.vim-undo-dir")
call mkdir("/tmp/.vim-undo-dir", "", 0700)
endif
set undodir=/tmp/.vim-undo-dir
set undofile
" *last-position-jump*
" This autocommand jumps to the last known position in a file
" just after opening it, if the '" mark is set:
:au BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit'
\ | exe "normal! g`\""
\ | endif
call plug#begin(stdpath('data') . '/plugged')
" I understand what these plugins do
Plug 'gruvbox-community/gruvbox' " color theme
Plug 'folke/which-key.nvim' " cheat sheet for leader key
Plug 'tpope/vim-surround' " quickly change surround char
Plug 'tpope/vim-commentary' " toggle comments
Plug 'bkad/CamelCaseMotion' " jumpToCamelCase
Plug 'ThePrimeagen/vim-be-good' " vim game to git gud
" I don no
" Plebvim LSP
Plug 'neovim/nvim-lspconfig' " Quickstart configurations for the Nvim LSP client
Plug 'glepnir/lspsaga.nvim' " A light-weight lsp plugin based on neovim built-in lsp with highly a performant UI.
Plug 'kabouzeid/nvim-lspinstall' " Provides the missing :LspInstall for nvim-lspconfig
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " nvim wrapper around tree-sitter - 'An incremental parsing system for programming tools'
" Plug 'hrsh7th/nvim-compe'
Plug 'simrat39/symbols-outline.nvim' " Debugger like Symbols tree
" telescope
Plug 'nvim-lua/plenary.nvim' " telescope dependency
Plug 'nvim-telescope/telescope.nvim' " file finder
" TODO: learn how they work
Plug 'tpope/vim-fugitive' " git in vim wrapper
Plug 'mbbill/undotree' " git like undo history
Plug 'sbdchd/neoformat' " run formatter like prettier
call plug#end()
" UI {
set background=dark
set cursorline
colorscheme gruvbox
set termguicolors " enable true colors support
" }
" https://vim.fandom.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_1)#Mode-specific_maps
" Commands Mode
" -------- ----
" nmap, nnoremap, nunmap Normal mode
" imap, inoremap, iunmap Insert and Replace mode
" vmap, vnoremap, vunmap Visual and Select mode
" xmap, xnoremap, xunmap Visual mode
" smap, snoremap, sunmap Select mode
" cmap, cnoremap, cunmap Command-line mode
" omap, onoremap, ounmap Operator pending mode
let mapleader="\<Space>"
nnoremap <leader><CR> :so ~/.config/nvim/init.vim<CR>
nnoremap Y y$
nnoremap <leader>pv :Ex<CR>
nnoremap <leader>u :UndotreeShow<CR>
" copy/paste to/from clipboard
nnoremap <leader>y "+y
vnoremap <leader>y "+y
nnoremap <leader>p "+p
vnoremap <leader>p "+p
" yank whole file
nnoremap <leader>Y gg"+yG
" don't write to register
vnoremap <leader>d "_d
nnoremap <leader>d "_d
xnoremap <leader>P "_dP
nnoremap <C-j> :cnext<CR>
nnoremap <C-k> :cprev<CR>
" move selected line
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
map <leader>ss :setlocal spell!<cr>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
" Find files using Telescope command-line sugar.
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
" window remaps
" Ctrl+w s for :split
" Ctrl+w v for :vsplit
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" require'lspconfig'.phpactor.setup{}
lua << EOF
require'lspconfig'.intelephense.setup{}
require'lspconfig'.html.setup{}
require("which-key").setup {}
EOF
" LSP autocomplete
set completeopt=menuone,noselect
let g:completion_matching_strategy_list = ['exact', 'substring', 'fuzzy']
nnoremap <leader>vd :lua vim.lsp.buf.definition()<CR>
nnoremap <leader>vi :lua vim.lsp.buf.implementation()<CR>
nnoremap <leader>vsh :lua vim.lsp.buf.signature_help()<CR>
nnoremap <leader>vrr :lua vim.lsp.buf.references()<CR>
nnoremap <leader>vrn :lua vim.lsp.buf.rename()<CR>
nnoremap <leader>vh :lua vim.lsp.buf.hover()<CR>
nnoremap <leader>vca :lua vim.lsp.buf.code_action()<CR>
nnoremap <leader>vsd :lua vim.lsp.diagnostic.show_line_diagnostics(); vim.lsp.util.show_line_diagnostics()<CR>
nnoremap <leader>vn :lua vim.lsp.diagnostic.goto_next()<CR>
nnoremap <leader>vll :call LspLocationList()<CR>
" https://github.com/ThePrimeagen/.dotfiles/blob/master/nvim/.config/nvim/plugin/lsp.vim
" https://github.com/hrsh7th/nvim-compe
" let g:compe = {}
" let g:compe.enabled = v:true
" let g:compe.autocomplete = v:true
" let g:compe.debug = v:false
" let g:compe.min_length = 1
" let g:compe.preselect = 'enable'
" let g:compe.throttle_time = 80
" let g:compe.source_timeout = 200
" let g:compe.incomplete_delay = 400
" let g:compe.max_abbr_width = 100
" let g:compe.max_kind_width = 100
" let g:compe.max_menu_width = 100
" let g:compe.documentation = v:true
" let g:compe.source = {}
" let g:compe.source.path = v:true
" let g:compe.source.buffer = v:true
" let g:compe.source.calc = v:true
" let g:compe.source.nvim_lsp = v:true
" let g:compe.source.nvim_lua = v:true
" let g:compe.source.vsnip = v:true
" inoremap <silent><expr> <C-Space> compe#complete()
" inoremap <silent><expr> <CR> compe#confirm('<CR>')
" inoremap <silent><expr> <C-e> compe#close('<C-e>')
" inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })
" inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment