2020-03-19 15:56:18 +00:00
if empty ( glob ( '~/.config/nvim/autoload/plug.vim' ) ) "
silent ! curl - fLo ~ /.config/ nvim /autoload/ plug .vim - - create - dirs
\ https :// raw .githubusercontent .com /junegunn/ vim - plug /master/ plug .vim
autocmd VimEnter * PlugInstall - - sync | source $MYVIMRC
endif
2020-03-20 14:02:30 +00:00
call plug #begin ( '~/.config/nvim/bundle' )
2020-03-19 15:56:18 +00:00
2021-09-04 09:11:03 +00:00
" evaluating
" #nvim-treesitter {{{
" https://github.com/nvim-treesitter/nvim-treesitter
Plug 'nvim-treesitter/nvim-treesitter' , {'do' : ':TSUpdate' } " update the parsers on update
" config needs to be after call to plug#end
" Treesitter uses a different parser for every language, which needs to be generated
" If the language is already supported by nvim-treesitter, you can install it with
" :TSInstall <language_to_install>
" - can use tab completion with this
" Parsers not on this list can be added manually
"
" If you update nvim-treesitter and want to make sure the parser is at the latest compatible version (as specified in nvim-treesitter's lockfile.json), use
" :TSUpdate {language}.
" To update all parsers unconditionally, use
" :TSUpdate all or just :TSUpdate.
"
" Each module provides a distinct tree-sitter-based feature such as highlighting, indentation, or folding; see :h nvim-treesitter-modules or "Available modules" below for a list of modules and their options.
" All modules are disabled by default and need to be activated explicitly in your init.vim
"
" Each module can also be enabled or disabled interactively through the following commands:
" :TSBufEnable {module} " enable module on current buffer
" :TSBufDisable {module} " disable module on current buffer
" :TSEnableAll {module} [{ft}] " enable module on every buffer. If filetype is specified, enable only for this filetype.
" :TSDisableAll {module} [{ft}] " disable module on every buffer. If filetype is specified, disable only for this filetype.
" :TSModuleInfo [{module}] " list information about modules state for each filetype
"
" Check :h nvim-treesitter-commands for a list of all available commands. It may be necessary to reload the buffer (e.g., via :e) after enabling a module interactively.
"}}}
2021-09-04 12:27:58 +00:00
" #playground {{{
" https://github.com/nvim-treesitter/playground
Plug 'nvim-treesitter/playground'
2021-09-04 12:37:48 +00:00
"}}}
" #vim-lspconfig {{{
" https://github.com/neovim/nvim-lspconfig
" https://github.com/neovim/nvim-lspconfig/wiki
Plug 'neovim/nvim-lspconfig'
2021-09-04 09:11:03 +00:00
" setings after plug#end
"}}}
" keeping
2019-09-13 14:27:38 +00:00
" #vim-hexokinase {{{
2020-04-07 19:38:42 +00:00
" https://github.com/chrisbra/Colorizer
2021-09-04 09:11:03 +00:00
" display colors asynchronously
2020-04-07 19:38:42 +00:00
Plug 'chrisbra/Colorizer'
" let g:colorizer_use_virtual_text = 1
nnoremap < silent > < cr > cc :ColorToggle < CR >
2019-09-13 14:27:38 +00:00
"}}}
" #delimitMate{{{
" https://github.com/Raimondi/delimitMate
2021-09-04 09:11:03 +00:00
" automatic quote, paranthesis,etc closing.
2019-09-13 14:27:38 +00:00
Plug 'Raimondi/delimitMate'
let delimitMate_expand_cr = 1
let delimitMate_expand_space = 1
"}}}
" #emmet-vim {{{
" https://github.com/mattn/emmet-vim
Plug 'mattn/emmet-vim'
let g :user_emmet_leader_key = ',,'
let g :user_emmet_settings = {
\ 'indentation' : ' ' ,
\}
"}}}
" #gitgutter {{{
" https://github.com/airblade/vim-gitgutter/blob/master/README.mkd
2021-09-04 09:11:03 +00:00
" show git diff in sign column
2019-09-13 14:27:38 +00:00
Plug 'airblade/vim-gitgutter'
2020-04-09 10:27:47 +00:00
nmap ]h < Plug > ( GitGutterNextHunk )
nmap [h < Plug > ( GitGutterPrevHunk )
omap ih < Plug > ( GitGutterTextObjectInnerPending )
omap ah < Plug > ( GitGutterTextObjectOuterPending )
xmap ih < Plug > ( GitGutterTextObjectInnerVisual )
xmap ah < Plug > ( GitGutterTextObjectOuterVisual )
2019-09-13 14:27:38 +00:00
"}}}
" #MatchTagAlways{{{
2021-09-04 09:11:03 +00:00
" always highlights xml/html tags enclosing cursor
2019-09-13 14:27:38 +00:00
" https://github.com/Valloric/MatchTagAlways
Plug 'Valloric/MatchTagAlways'
let g :mta_filetypes = {
\ 'jinja' : 1 ,
\ 'html' : 1 ,
\ 'vue' : 1 ,
\ 'xhtml' : 1 ,
\ 'xml' : 1 ,
\}
"}}}
" #quickscope{{{
2021-09-04 09:11:03 +00:00
" highlights unique characters when using f, F, etc
2019-09-13 14:27:38 +00:00
" https://github.com/unblevable/quick-scope
Plug 'unblevable/quick-scope'
let g :qs_highlight_on_keys = ['f' , 'F' , 't' , 'T' ]
"}}}
" #switch {{{
"https://github.com/AndrewRadev/switch.vim
Plug 'AndrewRadev/switch.vim'
let g :switch_mapping = '<space>-'
let g :switch_custom_definitions = [
\ ['0' , '1' ],
\ ['ease-in' , 'ease-out' , 'ease-in-out' , 'linear' ],
\ ['auto' , 'none' ],
\ ['left' , 'right' ],
\ ['top' , 'bottom' ],
\ ['row' , 'column' ],
\ ['relative' , 'absolute' , 'fixed' ],
\ ['private' , 'public' , 'protected' ]
\ ]
"}}}
" #ultisnips {{{
" https://github.com/sirver/UltiSnips
Plug 'SirVer/ultisnips'
" and some snippets
" https://github.com/honza/vim-snippets
" Plug 'honza/vim-snippets'
nnoremap < space > ul :call ListUltisnips ( ) < cr >
inoremap jkul < c - o > :call ListUltisnips ( ) < cr >
let g :UltiSnipsSnippetsDir = '~/.vim/UltiSnips'
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g :UltiSnipsExpandTrigger = '<tab>'
let g :UltiSnipsJumpForwardTrigger = '<tab>'
let g :UltiSnipsJumpBackwardTrigger = '<s-tab>'
let g :UltiSnipsEditSplit = 'horizontal'
function ! ListUltisnips ( ) abort "{{{
let l :snips = UltiSnips #SnippetsInCurrentScope ( 1 )
let l :keylist = sort ( keys ( l :snips ) )
echo ' --------------------------------------------------'
for l :key in l :keylist
echo printf ( " %-10s\t%s" , l :key , l :snips [l :key ])
endfor
echo '---------------------------------------------------'
endfunction
"}}}
function ! CompleteSnippets ( findstart , base ) "{{{
if a :findstart
let l :line = getline ( '.' )
let l :start = col ( '.' ) - 1
while l :start > 0 && l :line [l :start - 1 ] = ~ '\a'
let l :start - = 1
endwhile
return l :start
else
let l :res = []
let l :snips = UltiSnips #SnippetsInCurrentScope ( 1 )
let l :keylist = sort ( keys ( l :snips ) )
for l :key in l :keylist
if l :key = ~ '^' . a :base
let l :item = {'word' : l :key , 'menu' : l :snips [l :key ]}
call add ( l :res , l :item )
endif
endfor
return l :res
endif
endfunction
"}}}
set completefunc = CompleteSnippets
"}}}
2020-03-19 15:56:18 +00:00
" #Netrw {{{
let g :netrw_liststyle = 3
2020-03-20 17:31:55 +00:00
let g :netrw_list_hide = netrw_gitignore #Hide ( )
2020-05-03 16:50:45 +00:00
let g :netrw_preview = 0
let g :netrw_winsize = 50
let g :netrw_altv = &spr
let g :netrw_alto = 1
2020-03-19 15:56:18 +00:00
let g :netrw_altfile = 1
let g :netrw_mousemaps = 0
"}}}
" #Obsession{{{
" fork of tpope/vim-obsession
Plug 'studio-vx/vim-obsession'
"}}}
" #tcomment_vim{{{
" https://github.com/tomtom/tcomment_vim
Plug 'tomtom/tcomment_vim'
"}}}
2021-09-04 09:11:03 +00:00
" #vim-rsi{{{
"https://github.com/tpope/vim-rsi
Plug 'tpope/vim-rsi'
"}}}
" #wakatime{{{
" https://wakatime.com/vim
Plug 'wakatime/vim-wakatime'
"}}}
" #vim-repeat{{{
" https://github.com/tpope/vim-repeat
" makes repeat . work for more stuff
Plug 'tpope/vim-repeat'
"}}}
" #vim-surround{{{
Plug 'tpope/vim-surround'
"}}}
" reconfigure and learn to use properly
2020-03-19 15:56:18 +00:00
" #vim-fzf {{{
" https://github.com/junegunn/fzf.vim
2020-03-22 21:03:59 +00:00
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
nnoremap < space > fg :GFiles < CR >
nnoremap < space > ff :Files < CR >
2020-09-17 16:40:05 +00:00
nnoremap < space > fh :History < CR >
2020-03-22 21:03:59 +00:00
nnoremap < space > ft :Tags < CR >
nnoremap < space > fb :Buffers < CR >
2020-09-17 16:40:05 +00:00
nnoremap < space > fH :Helptags < CR >
2020-03-22 21:03:59 +00:00
let g :fzf_preview_window = 'right:60%'
let g :fzf_colors =
\ { 'fg' : ['fg' , 'Normal' ],
\ 'bg' : ['bg' , 'Normal' ],
\ 'hl' : ['fg' , 'Label' ],
\ 'fg+' : ['fg' , 'CursorLine' , 'CursorColumn' , 'Normal' ],
\ 'bg+' : ['bg' , 'CursorLine' , 'CursorColumn' ],
\ 'hl+' : ['fg' , 'WildMenu' ],
\ 'info' : ['fg' , 'Comment' ],
\ 'border' : ['fg' , 'Ignore' ],
\ 'prompt' : ['fg' , 'Constant' ],
\ 'pointer' : ['fg' , 'Special' ],
\ 'marker' : ['fg' , 'Keyword' ],
\ 'spinner' : ['fg' , 'Label' ],
\ 'header' : ['fg' , 'Comment' ] }
2020-03-19 15:56:18 +00:00
"}}}
2021-09-04 09:11:03 +00:00
" #vim-shellcheck{{{
" https://github.com/itspriddle/vim-shellcheck
Plug 'itspriddle/vim-shellcheck'
2020-03-19 15:56:18 +00:00
2021-09-04 09:11:03 +00:00
"}}}
2020-03-19 15:56:18 +00:00
" #vim-markdown{{{
" https://github.com/plasticboy/vim-markdown
Plug 'plasticboy/vim-markdown'
let g :vim_markdown_toc_autofit = 1
let g :vim_markdown_fenced_languages = ['bash=sh' ]
"}}}
2021-09-04 09:11:03 +00:00
" #undotree {{{
Plug 'mbbill/undotree'
nnoremap < space > ut :UndotreeToggle < cr >
2020-03-19 15:56:18 +00:00
"}}}
2021-09-04 09:11:03 +00:00
" do i still need, can i replace?
" #vim-dispatch{{{
" https://github.com/tpope/vim-dispatch
Plug 'tpope/vim-dispatch'
2020-03-19 15:56:18 +00:00
"}}}
2021-09-04 09:11:03 +00:00
" #phpcomplete.vim{{{
" improved php completion
" https://github.com/shawncplus/phpcomplete.vim
Plug 'shawncplus/phpcomplete.vim'
" https://github.com/dsawardekar/wordpress.vim
" For up to date Wordpress Files see:
" https://github.com/joseluis/wordpress.vim-generator
2020-03-19 15:56:18 +00:00
"}}}
2021-09-04 09:11:03 +00:00
" #vim-floaterm{{{
" https://github.com/voldikss/floaterm
" allows to open floating terminal
Plug 'voldikss/vim-floaterm'
let g :floaterm_opener = 'edit'
nnoremap < space > lf :FloatermNew - - height = 0 .9 - - width = 0 .9 lf < CR >
nnoremap < space > lg :FloatermNew - - height = 0 .9 - - width = 0 .9 lazygit < CR >
"}}}
" #vim-Jinja2-Syntax{{{
" https://github.com/studio-vx/Vim-Jinja2-Syntax
" original: https://github.com/Glench/Vim-Jinja2-Syntax
Plug 'studio-vx/Vim-Jinja2-Syntax'
"}}}
" ------------------------------------------------------------------------------
2020-03-19 15:56:18 +00:00
call plug #end ( )
runtime macros /matchit .vim
2019-09-13 14:27:38 +00:00
2021-09-04 09:11:03 +00:00
" Configurations
" #nvim-treesitter {{{
lua < < EOF
require 'nvim-treesitter.configs' .setup {
ensure_installed = "maintained" , - - one of "all" , "maintained" ( parsers with maintainers ) , or a list of languages
ignore_install = { "c" }, - - List of parsers to ignore installing
highlight = {
enable = true , - - false will disable the whole extension
disable = { "c" , "rust" }, - - list of language that will be disabled
- - Setting this to true will run `:h syntax ` and tree - sitter at the same time .
- - Set this to `true ` if you depend on 'syntax' being enabled ( like for indentation ) .
- - Using this option may slow down your editor , and you may see some duplicate highlights .
- - Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false ,
},
}
EOF
"}}}
" #nvim-lspconfig {{{
" https://github.com/neovim/nvim-lspconfig
" https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md
lua < < EOF
- - npm install - g typescript typescript - language - server
require 'lspconfig' .tsserver .setup {}
- - npm install - g vim - language - server
require 'lspconfig' .vimls .setup {}
- - npm install - g pyright
require 'lspconfig' .pyright .setup {}
- - phpactor installation -
- - https :// phpactor .readthedocs .io /en/ master /usage/ standalone .html
require 'lspconfig' .phpactor .setup {}
- - npm i - g vscode - langservers - extracted
require 'lspconfig' .cssls .setup {}
- - npm install - g vls
require 'lspconfig' .vuels .setup {}
- - npm i - g bash - language - server
- - TODO - don 't run for sh files but have something else instead - shellcheck ?
require 'lspconfig' .bashls .setup {}
- - npm install - g yaml - language - server
require 'lspconfig' .yamlls .setup {}
- - npm i - g stylelint - lsp
require 'lspconfig' .stylelint_lsp .setup {}
- - https :// github .com /neovim/ nvim - lspconfig /wiki
require 'lspconfig' .tailwindcss .setup {}
2021-09-04 10:59:31 +00:00
- - EOF
- - "}}}
- - [efm - langserver ] {{{
- - " npm install -g eslint_d
2021-09-04 09:11:03 +00:00
local eslint = {
lintCommand = "eslint_d -f unix --stdin --stdin-filename ${INPUT}" ,
lintStdin = true ,
lintFormats = {"%f:%l:%c: %m" },
lintIgnoreExitCode = true ,
formatCommand = "eslint_d --fix-to-stdout --stdin --stdin-filename=${INPUT}" ,
formatStdin = true
}
local shellcheck = {
lintCommand = "shellcheck -f gcc -x" ,
lintSource = "shellcheck" ,
lintFormats = {
"%f:%l:%c: %trror: %m",
"%f:%l:%c: %tarning: %m",
"%f:%l:%c: %tote: %m",
}
}
2021-09-04 10:40:16 +00:00
local flake8 = {
lintCommand = "flake8 --stdin-display-name ${INPUT} -" ,
lintStdin = true ,
lintFormats = {"%f:%l:%c: %m" }
}
local black = {
formatCommand = "black --quiet -" ,
formatStdin = true
}
- - sudo pacman - Syu jq
local jq = {
lintCommand = "jq ."
}
- - npm install - g fixjson
local fixjson = {
formatCommand = "fixjson"
}
2021-09-04 09:11:03 +00:00
local util = require "lspconfig" .util
2021-09-04 10:59:31 +00:00
local on_attach_efm = function ( client )
2021-09-04 10:40:16 +00:00
if client .resolved_capabilities .document_formatting then
vim .cmd [[augroup lsp_formatting ]]
vim .cmd [[autocmd ! ]]
2021-09-04 12:27:58 +00:00
vim .cmd [[autocmd BufWritePre < buffer > :lua vim .lsp .buf .formatting_seq_sync ( {}, 1000 ) ]]
2021-09-04 10:40:16 +00:00
vim .cmd [[augroup END ]]
end
end
2021-09-04 09:11:03 +00:00
require "lspconfig" .efm .setup {
init_options = {documentFormatting = true },
2021-09-04 10:59:31 +00:00
on_attach = on_attach_efm ,
2021-09-04 10:40:16 +00:00
filetypes = {"javascript" , "typescript" , "json" , "sh" , "python" },
2021-09-04 09:11:03 +00:00
root_dir = function ( fname )
return util .root_pattern ( "tsconfig.json" ) ( fname ) or
util .root_pattern ( ".eslintrc.js" , ".git" ) ( fname ) ;
end ,
settings = {
rootMarkers = {".eslintrc.js" , ".git/" },
languages = {
javascript = {eslint },
typescript = {eslint },
2021-09-04 10:40:16 +00:00
json = {jq , fixjson },
python = { flake8 , black } ,
2021-09-04 09:11:03 +00:00
sh = {shellcheck }
}
}
}
EOF
2021-09-04 10:40:16 +00:00
" }}}
2021-09-04 10:59:31 +00:00
" #nvim-lspconfig {{{
2021-09-04 10:40:16 +00:00
lua < < EOF
local nvim_lsp = require ( 'lspconfig' )
- - Use an on_attach function to only map the following keys
- - after the language server attaches to the current buffer
local on_attach = function ( client , bufnr )
local function buf_set_keymap ( ...) vim .api .nvim_buf_set_keymap ( bufnr , ...) end
local function buf_set_option ( ...) vim .api .nvim_buf_set_option ( bufnr , ...) end
- - Enable completion triggered by < c - x > < c - o >
buf_set_option ( 'omnifunc' , 'v:lua.vim.lsp.omnifunc' )
- - Mappings .
local opts = { noremap = true , silent = true }
- - See `:help vim .lsp .*` for documentation on any of the below functions
buf_set_keymap ( 'n' , 'gD' , '<cmd>lua vim.lsp.buf.declaration()<CR>' , opts )
buf_set_keymap ( 'n' , 'gd' , '<cmd>lua vim.lsp.buf.definition()<CR>' , opts )
buf_set_keymap ( 'n' , 'K' , '<cmd>lua vim.lsp.buf.hover()<CR>' , opts )
buf_set_keymap ( 'n' , 'gi' , '<cmd>lua vim.lsp.buf.implementation()<CR>' , opts )
buf_set_keymap ( 'n' , '<C-k>' , '<cmd>lua vim.lsp.buf.signature_help()<CR>' , opts )
2021-09-04 11:21:41 +00:00
- - buf_set_keymap ( 'n' , '<space>wa' , '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>' , opts )
- - buf_set_keymap ( 'n' , '<space>wr' , '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>' , opts )
- - buf_set_keymap ( 'n' , '<space>wl' , '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>' , opts )
2021-09-04 10:40:16 +00:00
buf_set_keymap ( 'n' , '<space>D' , '<cmd>lua vim.lsp.buf.type_definition()<CR>' , opts )
buf_set_keymap ( 'n' , '<space>rn' , '<cmd>lua vim.lsp.buf.rename()<CR>' , opts )
buf_set_keymap ( 'n' , '<space>ca' , '<cmd>lua vim.lsp.buf.code_action()<CR>' , opts )
buf_set_keymap ( 'n' , 'gr' , '<cmd>lua vim.lsp.buf.references()<CR>' , opts )
buf_set_keymap ( 'n' , '<space>e' , '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>' , opts )
buf_set_keymap ( 'n' , '[d' , '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>' , opts )
buf_set_keymap ( 'n' , ']d' , '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>' , opts )
buf_set_keymap ( 'n' , '<space>q' , '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>' , opts )
buf_set_keymap ( 'n' , '<space>f' , '<cmd>lua vim.lsp.buf.formatting()<CR>' , opts )
end
- - Use a loop to conveniently call 'setup' on multiple servers and
- - map buffer local keybindings when the language server attaches
local servers = {
'bashls' ,
'cssls' ,
'phpactor' ,
'pyright' ,
'stylelint_lsp' ,
'tailwindcss' ,
'tsserver' ,
'vimls' ,
'vuels'
}
for _ , lsp in ipairs ( servers ) do
nvim_lsp [lsp ].setup {
on_attach = on_attach ,
flags = {
debounce_text_changes = 150 ,
}
}
end
EOF
2021-09-04 09:11:03 +00:00
"}}}
2019-09-13 14:27:38 +00:00
" vim: set fdm=marker ft=vim: