~mdkcore/dotfiles

ed1ebeb89662cb57e5710dc003d753c1e8add508 — Rodrigo Oliveira 1 year, 7 months ago bb6041b + 313e4ff
Merge branch 'nvim.lua'
M .install.conf.yaml => .install.conf.yaml +7 -13
@@ 22,18 22,16 @@
    ~/.profile: profile
    ~/.bashrc: bashrc
    ~/.zshrc: zshrc
    # vim and its bundles
    ~/.vimrc: nvim/init.vim
    ~/.vim/bundles.vim:
        create: true
        path: nvim/bundles.vim
    # neovim
    ~/.config/nvim/bundles.vim:
    ~/.config/nvim/init.lua:
        create: true
        path: nvim/init.lua
    ~/.config/nvim/lua:
        create: true
        path: nvim/bundles.vim
    ~/.config/nvim/init.vim:
        path: nvim/lua
    ~/.config/nvim/after:
        create: true
        path: nvim/init.vim
        path: nvim/after
    ~/.pythonrc: pythonrc
    # tig
    ~/.config/tig: tig


@@ 97,10 95,6 @@
    -
        - git clone --recursive https://github.com/rizsotto/Bear.git ~/downloads/GIT/Bear
        - "Cloning BEAR dependency (You should compile/install it afterwards)"
    # Vundle
    -
        - git clone --recursive https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
        - "Cloning VUNDLE dependency (Run it afterwards: vim (or nvim) +PluginInstall +qall)"
    # weechat
    -
      - git clone --recursive https://github.com/weechat/scripts.git ~/downloads/GIT/weechat-scripts

A .pre-commit-config.yaml => .pre-commit-config.yaml +18 -0
@@ 0,0 1,18 @@
repos:
  - repo: https://github.com/JohnnyMorganz/StyLua
    rev: v0.16.1
    hooks:
      - id: stylua
        name: StyLua
        # language: rust
        # types: [lua]
        args: [-f, nvim/.stylua.toml, "-"]
  - repo: https://github.com/lunarmodules/luacheck
    rev: v1.1.0
    hooks:
      - id: luacheck
        name: luacheck
        # language: system
        # language: lua
        # types: [lua]
        args: [--config, nvim/.luacheckrc, "-"]

M README.md => README.md +12 -0
@@ 18,6 18,18 @@ Scripts
There are some scripts bundled on my dotfiles (more like "helpers"), related to specific things (e.g. managing audio volume on i3).  
For other scripts, see my [dotbins repo](https://git.sr.ht/~mdkcore/dotbins) ;)

# Code style
Currently only neovim lua configuration files are covered by code-styling
tools (`stylua` and `luacheck`; stylua is automatically installed, while
luacheck not).

Also `pre-commit` must be installed in the system, and it can be installed as a
git commit hook by running:

```shell
pre-commit install
```

Note for Slackware users
------------------------


A nvim/.gitignore => nvim/.gitignore +2 -0
@@ 0,0 1,2 @@
plugin/
.luarc.json

A nvim/.luacheckrc => nvim/.luacheckrc +14 -0
@@ 0,0 1,14 @@
-- vim: ft=lua tw=120

globals = { "use" }
read_globals = { "vim" }

ignore = {
  "122",
  "212",
  "411",
}

exclude_files = {
  "nvim/plugin/",
}

A nvim/.stylua.toml => nvim/.stylua.toml +2 -0
@@ 0,0 1,2 @@
indent_type = "Spaces"
indent_width = 2

A nvim/README.md => nvim/README.md +16 -0
@@ 0,0 1,16 @@
# LSP

## lua
```shell
xbps-install luarocks-lua53 lua53-devel lua-language-server
```

## markdown
```shell
wget https://github.com/artempyanykh/marksman/releases/latest/download/marksman-linux -O ~/.local/bin/marksman && chmod +x ~/.local/bin/marksman
```

## c/c++
```shell
xbps-install clangd Bear
```

A nvim/after/ftplugin/c.lua => nvim/after/ftplugin/c.lua +21 -0
@@ 0,0 1,21 @@
-- update c/c++ parsers
local ok, treesitter = pcall(require, "nvim-treesitter.install")
if not ok then
  return
end
treesitter.commands.TSUpdate["run"]("c", "cpp")

-- additional capabilities supported by nvim-cmp
local capabilities = require("cmp_nvim_lsp").default_capabilities()

-- setup c/c++ server
require("lspconfig").clangd.setup({
  on_attach = require("configs.keybindings").lsp_keybindings,
  capabilities = capabilities,
  cmd = {
    "clangd",
    "--completion-style=detailed",
    "--suggest-missing-includes",
  },
})
require("lspconfig").clangd.manager.try_add_wrapper()

A nvim/after/ftplugin/cpp.lua => nvim/after/ftplugin/cpp.lua +1 -0
@@ 0,0 1,1 @@
vim.cmd.runtime({ "after/ftplugin/c.lua", bang = true })

A nvim/after/ftplugin/lua.lua => nvim/after/ftplugin/lua.lua +37 -0
@@ 0,0 1,37 @@
vim.o.colorcolumn = "120"
vim.o.tabstop = 2
vim.o.shiftwidth = 2

-- update lua parser
local ok, treesitter = pcall(require, "nvim-treesitter.install")
if not ok then
  return
end
treesitter.commands.TSUpdate["run"]("lua")

-- additional capabilities supported by nvim-cmp
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)

-- setup c/c++ server
require("lspconfig").lua_ls.setup({
  on_attach = require("configs.keybindings").lsp_keybindings,
  capabilities = capabilities,
  settings = {
    Lua = {
      runtime = {
        version = "LuaJIT",
      },
      diagnostics = {
        globals = { "vim" },
      },
      workspace = {
        library = vim.api.nvim_get_runtime_file("", true),
      },
      telemetry = {
        enable = false,
      },
    },
  },
})
require("lspconfig").lua_ls.manager.try_add_wrapper()

A nvim/after/ftplugin/markdown.lua => nvim/after/ftplugin/markdown.lua +30 -0
@@ 0,0 1,30 @@
--[[
mixing [1] and [2] on here
[1] https://arcticicestudio.github.io/styleguide-markdown/
[2] https://google.github.io/styleguide/docguide/style.html

"avoid using a character limit per line for flowing text, but try to use a maximum line length of 120 characters
(including whitespaces) for all other document elements"
https://arcticicestudio.github.io/styleguide-markdown/rules/whitespace.html#maximum-line-length.
--]]
vim.o.colorcolumn = "120"
vim.o.tabstop = 2
vim.o.shiftwidth = 2

-- update markdown parser
local ok, treesitter = pcall(require, "nvim-treesitter.install")
if not ok then
  return
end
treesitter.commands.TSUpdate["run"]("markdown")
treesitter.commands.TSUpdate["run"]("markdown_inline")

-- additional capabilities supported by nvim-cmp
local capabilities = require("cmp_nvim_lsp").default_capabilities()

-- setup markdown server
require("lspconfig").marksman.setup({
  on_attach = require("configs.keybindings").lsp_keybindings,
  capabilities = capabilities,
})
require("lspconfig").marksman.manager.try_add_wrapper()

D nvim/bundles.vim => nvim/bundles.vim +0 -289
@@ 1,289 0,0 @@
" Installation
filetype off
call vundle#begin()

" Vundle | https://github.com/VundleVim/Vundle.vim
Plugin 'gmarik/Vundle.vim'


if has('nvim')
    " vim-airline | https://github.com/vim-airline/vim-airline
    Plugin 'vim-airline/vim-airline'
    Plugin 'vim-airline/vim-airline-themes'
endif


" GitGutter | https://github.com/airblade/vim-gitgutter
Plugin 'airblade/vim-gitgutter'


" EasyMotion | https://github.com/easymotion/vim-easymotion
Plugin 'easymotion/vim-easymotion'


if has('nvim')
    " python specific
    " jedi | https://github.com/davidhalter/jedi
    Plugin 'davidhalter/jedi'
    " deoplete-jedi | https://github.com/zchee/deoplete-jedi
    Plugin 'zchee/deoplete-jedi'

    " c/c++ (clang) specific
    " deoplete-clang2 | https://github.com/tweekmonster/deoplete-clang2
    Plugin 'tweekmonster/deoplete-clang2'

    " deoplete.nvim | https://github.com/Shougo/deoplete.nvim
    " run after PluginInstall: UpdateRemotePlugins
    Plugin 'Shougo/deoplete.nvim'
endif


" neosnippet dependencies
" https://github.com/honza/vim-snippets
Plugin 'honza/vim-snippets'
" neosnippet.vim | https://github.com/shougo/neosnippet.vim
Plugin 'shougo/neosnippet.vim'
" neosnippet-snippets | https://github.com/Shougo/neosnippet-snippets
Plugin 'shougo/neosnippet-snippets'


" nerdcommenter | https://github.com/scrooloose/nerdcommenter
Plugin 'scrooloose/nerdcommenter'


" auto-pairs | https://github.com/jiangmiao/auto-pairs
Plugin 'jiangmiao/auto-pairs'


" neomru | https://github.com/Shougo/neomru.vim
Plugin 'Shougo/neomru.vim'
" neoyank | https://github.com/Shougo/neoyank.vim
Plugin 'Shougo/neoyank.vim'
" denite.nvim | https://github.com/Shougo/denite.nvim
Plugin 'Shougo/denite.nvim'


" vim-tmux-navigator | https://github.com/christoomey/vim-tmux-navigator
Plugin 'christoomey/vim-tmux-navigator'


" context_filetype | https://github.com/Shougo/context_filetype.vim
Plugin 'Shougo/context_filetype.vim'


" FSwitch | https://github.com/vim-scripts/FSwitch
Plugin 'vim-scripts/FSwitch'


" Gundo | https://github.com/sjl/gundo.vim
Plugin 'sjl/gundo.vim'


" vim-qml | https://github.com/peterhoeg/vim-qml
Plugin 'peterhoeg/vim-qml'


" i3-vim-syntax | https://github.com/PotatoesMaster/i3-vim-syntax
Plugin 'PotatoesMaster/i3-vim-syntax'


" vim-polyglot | https://github.com/sheerun/vim-polyglot
Plugin 'sheerun/vim-polyglot'


" vim-pydocstring | https://github.com/heavenshell/vim-pydocstring.git
Plugin 'heavenshell/vim-pydocstring.git'


" vim-indent-guides | https://github.com/nathanaelkane/vim-indent-guides
Plugin 'nathanaelkane/vim-indent-guides'


" vim-flake8 | https://github.com/nvie/vim-flake8
Plugin 'nvie/vim-flake8'


" ale | https://github.com/w0rp/ale
Plugin 'w0rp/ale'


" fzf.vim | https://github.com/junegunn/fzf.vim
set rtp+=~/downloads/GIT/fzf
Plugin 'junegunn/fzf.vim'


" vim-devicons | https://github.com/ryanoasis/vim-devicons
Plugin 'ryanoasis/vim-devicons'


" base16-vim | https://github.com/chriskempson/base16-vim
Plugin 'chriskempson/base16-vim'

call vundle#end()
filetype plugin indent on


" Configuration
if has('nvim')
    " vim-airline | https://github.com/vim-airline/vim-airline
    let g:airline_powerline_fonts = 1
    let g:airline#extensions#tabline#enabled = 1
    let g:airline#extensions#tabline#show_close_button = 0
    let g:airline#extensions#tabline#show_buffers = 0
    " turning on ale integration
    let g:airline#extensions#ale#enabled = 1
endif


" EasyMotion | https://github.com/Lokaltog/vim-easymotion
let g:EasyMotion_leader_key = '<Leader>'


" deoplete-jedi | https://github.com/zchee/deoplete-jedi
let g:deoplete#sources#jedi#show_docstring = 1
" deoplete.nvim | https://github.com/Shougo/deoplete.nvim
let g:deoplete#enable_at_startup = 1
let g:deoplete#enable_smart_case = 1
autocmd CompleteDone * silent! pclose!


" neosnippet.vim | https://github.com/shougo/neosnippet.vim
let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets'
imap <C-k>     <Plug>(neosnippet_expand_or_jump)
smap <C-k>     <Plug>(neosnippet_expand_or_jump)
xmap <C-k>     <Plug>(neosnippet_expand_target)
if has('conceal')
  set conceallevel=2 concealcursor=niv
endif


" denite.nvim | https://github.com/Shougo/denite.nvim
" XXX
"nnoremap <F3> :UniteSessionSave 
call denite#custom#source(
    \"buffer,file,file_mru,file_rec,grep",
    \"matchers", ['matcher_fuzzy'])
call denite#custom#source('z', 'sorters', ['sorter_rank'])
    "\'start_filter': v:true,
call denite#custom#option('_', {
    \'prompt': 'î‚°',
    \'smartcase': v:true,
    \'short_source_names': v:true,
    \'empty': v:false,
    \'auto_resume': v:true,
    \'highlight_matched_char': 'Operator',
    \'highlight_mode_normal': 'CursorLine',
\})
let g:unite_source_file_mru_long_limit=3000
let g:unite_source_directory_mru_long_limit=3000
let g:unite_source_file_mru_limit=200
let g:unite_source_file_mru_filename_format=''

"" use 'the silver searcher' instead of 'grep' if available
if executable('ag')
    call denite#custom#var('grep', 'command', ['ag'])
    call denite#custom#var('grep', 'recursive_opts', [])
    call denite#custom#var('grep', 'pattern_opt', [])
    call denite#custom#var('grep', 'separator', ['--'])
    call denite#custom#var('grep', 'final_opts', [])
    call denite#custom#var('grep', 'default_opts', [
        \'--skip-vcs-ignores',
        \'--vimgrep',
        \'--hidden',
        \'--smart-case',
        \'--nocolor',
    \])
endif

" custom bindings
nnoremap <leader>* :DeniteCursorWord -buffer-name=grep grep:.<cr>
nnoremap <leader>i :Denite -buffer-name=file file<cr>
nnoremap <leader>r :Denite -buffer-name=file_rec file_rec<cr>
nnoremap <leader>m :Denite -buffer-name=file_mru file_mru<cr>
nnoremap <leader>p :Denite -buffer-name=files buffer file_mru file_rec<cr>
nnoremap <leader>h :Denite -buffer-name=buffer buffer<cr>
nnoremap <leader>y :Denite -buffer-name=yank neoyank<cr>
nnoremap <leader>/ :Denite -buffer-name=grep grep:.<cr>
" install exuberant-ctags
nnoremap <leader>o :Denite -buffer-name=outline -split=vertical -winwidth=60 -default-action=tabswitch outline<cr>
" XXX
"nnoremap <leader>s :Unite -no-split session<cr>

" TODO
"call denite#custom#alias('source', 'file_rec/git', 'file_rec')
"call denite#custom#var('file_rec/git', 'command',
      "\['git', 'ls-files', '-co', '--exclude-standard'])
"nnoremap <silent>,g :Denite -buffer-name=git-grep file_rec/git<cr>

" global mappings
call denite#custom#map('_', '<CR>', '<denite:do_action:tabopen>', 'noremap')
let _mode_mappings = [
    \['<C-n>', '<denite:move_to_next_line>', 'noremap'],
    \['<C-p>', '<denite:move_to_previous_line>', 'noremap'],
    \['<C-s>', '<denite:do_action:split>', 'noremap'],
    \['<C-v>', '<denite:do_action:vsplit>', 'noremap'],
    \['<C-r>', '<denite:do_action:switch>', 'noremap'],
\]
for each in _mode_mappings
    call denite#custom#map('insert', each[0], each[1], each[2])
    call denite#custom#map('normal', each[0], each[1], each[2])
endfor

" insert mode mappings
call denite#custom#map('insert', '<Esc>', '<denite:enter_mode:normal>', 'noremap')
" normal mode mappings


" vim-tmux-navigator | https://github.com/christoomey/vim-tmux-navigator
let g:tmux_navigator_disable_when_zoomed = 1


" FSwitch | https://github.com/vim-scripts/FSwitch
nnoremap <F7> :FSSplitLeft<cr>
nnoremap <F8> :FSHere<cr>


" Gundo
nnoremap <F5> :GundoToggle<CR>


" vim-pydocstring
nmap <silent> <C-_> <Plug>(pydocstring)


" vim-indent-guides
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
let g:indent_guides_auto_colors = 1
let g:indent_guides_color_change_percent = 2

" just autoload on python files; toggle with <leader>ig
augroup python_files
    autocmd!
    autocmd BufRead,BufNew *.py execute "IndentGuidesEnable"
    autocmd FileType python map <buffer> <F10> :call Flake8()<CR>
augroup END


" ale | https://github.com/w0rp/ale
let g:ale_completion_enabled = 0
let g:ale_sign_column_always = 1
let g:ale_sign_error = '‣'
let g:ale_sign_warning = '×'
let g:ale_set_highlights = 0
nmap <silent> <S-F6> <Plug>(ale_previous_wrap)
nmap <silent> <F6> <Plug>(ale_next_wrap)


" vim-devicons | https://github.com/ryanoasis/vim-devicons
" uname -s
let g:WebDevIconsOS = 'Linux'


" base16-vim | https://github.com/chriskempson/base16-vim
set termguicolors
if filereadable(expand("~/.vimrc_background"))
    let base16colorspace=256
    source ~/.vimrc_background
    let g:airline_theme='base16'
endif

A nvim/init.lua => nvim/init.lua +53 -0
@@ 0,0 1,53 @@
vim.g.mapleader = "f"
vim.g.maplocalleader = "f"

vim.o.updatetime = 250

vim.wo.number = true
vim.o.cursorline = true

vim.o.completeopt = "menuone,noselect"
vim.o.undofile = true
vim.o.splitright = true
vim.o.breakindent = true

vim.o.ignorecase = true
vim.o.smartcase = true

vim.o.tabstop = 4
vim.o.shiftwidth = 4
vim.o.expandtab = true
vim.o.smarttab = true

vim.o.mouse = nil

-- restore last cursor position
vim.cmd([[
  autocmd BufRead * autocmd FileType <buffer> ++once
      \ if &ft !~# 'commit\|rebase' && line("'\"") > 1 && line("'\"") <= line("$") | exe 'normal! g`"' | endif
]])

-- lsp UI configuration
vim.cmd([[
  autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false, scope="line"})
]])

local border = "rounded"
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
  border = border,
})
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
  border = border,
})
vim.diagnostic.config({
  virtual_text = false,
  underline = false,
  update_in_insert = true,
  float = {
    source = "always",
    border = "rounded",
  },
})

-- let the fun begin!
require("plugins")

D nvim/init.vim => nvim/init.vim +0 -201
@@ 1,201 0,0 @@
" Help:
"
" ZS  = save current file
" ZA  = save all opened files
" QQ  = quit all opened files
" F2  = paste toggle
" F3  = save session (uses unite-session)
" F4  = clear hl search
" F5  = Gundo toggle
" F6  = Next syntastic error (S-F6 = previous error)
" F7  = FSSplit left
" F8  = FSHere
" F9  = convert current file to utf-8
" F10 = run flake8-vim
" C-Space = YouCompleteMe
" CapsLock = toggle insert/normal mode
" + = expand region
" _ = shrink region
" up,down,left,right = move through splits
" C-[j,k,h,l] = move through splits AND tmux
" f = leader
"   EasyMotion
"   <leader>w =  forward
"   <leader>b =  backward
"   <leader>j =  line down
"   <leader>k =  line up
"   Unite
"   <leader>i = open from current-dir
"   <leader>r = open recursive
"   <leader>m = open Most Recent Used
"   <leader>p = open from all (buffer, MRU, bookmark, recursive)
"   <leader>h = open buffer
"   <leader>y = history/yank
"   <leader>/ = grep
"   <leader>o = outline
"   <leader>*word = grep search for word (word under cursor)
"   <leader>,g = git grep
"       <C-s> (in buffer) = horizontally split file
"       <C-v> (in buffer) = vertically split file
"       <C-r> (in buffer) = replace window with file
"   <leader>s = session
"   nerdcommenter
"   <leader>c<space> = comment/uncomment
"   <leader>y<space> = copy and comment
"   vim-indent-guides
"   <leader>ig = toggle indent guides
" // = search visual selected text
" C-_ = insert pydocstring (normal mode)
" neosnippet
"   C-k = expand or jump


if has('nvim')
    let g:python3_host_prog='$HOME/.pyenv/versions/py3nvim/bin/python3'
endif


set nocompatible


" bind caps lock (F16) to toggle insert/command mode
nmap [29~ <F16>
imap [29~ <F16>
vmap [29~ <F16>
nnoremap <silent><F16> :startinsert <CR>
inoremap <silent><F16> <Esc>l
vnoremap <silent><F16> <Esc>


" adios C-c!
nnoremap <c-c> <NOP>
inoremap <c-c> <NOP>
vnoremap <c-c> <NOP>


" use F2 to paste toggle
set pastetoggle=<F2>
" clear hl search
nnoremap <F4> :nohl<CR>
" convert to utf-8
nnoremap <F9> :e ++enc=utf-8<CR>
" save
nnoremap ZS :w<CR>
" save all
nnoremap ZA :wa<CR>
" quit all
nnoremap QQ :qa<CR>

" map leader to ','
let mapleader = "f"
let g:mapleader = "f"
" fast movement through splits
map <up> <c-w>k
map <down> <c-w>j
map <left> <c-w>h
map <right> <c-w>l


" vundle | git://github.com/gmarik/vundle.git
filetype off
set rtp+=$HOME/.vim/bundle/Vundle.vim
filetype plugin indent on


" bundles
source $HOME/.vim/bundles.vim


" basic setup
syntax on
set mouse-=a
set ai "Auto indent
set si "Smart indet
set wrap "Wrap lines
set nu " line numbering
set cursorline
set backspace=indent,eol,start
set browsedir=current
set ruler
set wildignore=*.o,*.e,*~
set wildignorecase
set wildmenu
set showmatch
set ignorecase
set smartcase
set scrolloff=5
set tabstop=4
set shiftwidth=4
set expandtab
set softtabstop=4
set laststatus=2
set ffs=unix,dos,mac
set clipboard+=unnamedplus
set noshowmode


" use # as comment on python files
au BufRead,BufNewFile *.py set nosmartindent


" doxygen syntax
let g:load_doxygen_syntax=1


" indent
set list listchars=tab:\└─,trail:•,extends:»,precedes:«,nbsp:×


" completion menu conf
set conceallevel=2
set concealcursor=vin
set completeopt=menu,menuone,longest,preview
set pumheight=20 " Limit popup menu height

highlight clear SignColumn

" restore the cursor on the last line of the file
if !has('nvim')
    set viminfo='10,\"100,:20,%,n~/.viminfo'
endif

if has("autocmd")
  autocmd BufReadPost *
    \ if line("'\"") > 1 && line("'\"") <= line("$") |
endif
function! ResCur()
  if line("'\"") <= line("$")
    normal! g`"
    return 1
  endif
endfunction

augroup resCur
  autocmd!
  autocmd BufWinEnter * call ResCur()
augroup END

" backups
set backup

" seach
set incsearch
set hlsearch

" limit at column 80
set colorcolumn=80
set updatetime=750
set ssop-=options
set modeline

" damn delay
set ttimeoutlen=0
augroup FastEscape
    autocmd!
    au InsertEnter * set timeoutlen=10
    au InsertLeave * set timeoutlen=1000
augroup END


" search visual selected text
vnoremap // y/<C-R>"<CR>"

A nvim/lua/configs/Comment.lua => nvim/lua/configs/Comment.lua +51 -0
@@ 0,0 1,51 @@
-- numToStr/Comment.nvim

local ok, comment = pcall(require, "Comment")
if not ok then
  return
end

comment.setup({
  -- disable all mappings and customize them below
  mappings = {
    basic = true,
    extra = false,
  },
  toggler = {
    line = '<leader>c<space>',
    block = '<leader>v<space>',
   },
  opleader = {
    line = '<leader>c<space>',
    block = '<leader>v<space>',
    },
})

-- normal-mode linewise yank
vim.api.nvim_set_keymap(
  "n",
  "<leader>cy",
  [[<cmd>yank<CR><cmd>lua require('Comment.api').call('toggle.linewise.current')<CR>g@$]],
  { noremap = true }
)
-- normal-mode blockwise yank
vim.api.nvim_set_keymap(
  "n",
  "<leader>vy",
  [[<cmd>yank<CR><cmd>lua require('Comment.api').call('toggle.blockwise.current')<CR>g@$]],
  { noremap = true }
)
-- visual-mode linewise yank
vim.api.nvim_set_keymap(
  "x",
  "<leader>cy",
  [[<ESC><cmd>'<,'>yank*<CR><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>]],
  { noremap = true }
)
-- visual-mode blockwise yank
vim.api.nvim_set_keymap(
  "x",
  "<leader>vy",
  [[<ESC><cmd>'<,'>yank*<CR><cmd>lua require('Comment.api').toggle.blockwise(vim.fn.visualmode())<CR>]],
  { noremap = true }
)

A nvim/lua/configs/colors.lua => nvim/lua/configs/colors.lua +12 -0
@@ 0,0 1,12 @@
-- theme and colors

local ok, base16 = pcall(require, "base16-colorscheme")
if not ok then
  return
end

base16.with_config({
  telescope = false,
})

vim.cmd("colorscheme base16-" .. vim.env.BASE16_THEME)

A nvim/lua/configs/gitsigns.lua => nvim/lua/configs/gitsigns.lua +22 -0
@@ 0,0 1,22 @@
-- gitsigns

local ok, gitsigns = pcall(require, "gitsigns")
if not ok then
  return
end

gitsigns.setup({
  signs = {
    add = { hl = "GitGutterAdd", numhl = "GitGutterAdd", text = "│" },
    change = { hl = "GitGutterChange", numhl = "GitGutterChange", text = "│" },
    delete = { hl = "GitGutterDelete", numhl = "GitGutterDelete", text = "_" },
    topdelete = { hl = "GitGutterDelete", numhl = "GitGutterDelete", text = "‾" },
    changedelete = { hl = "GitGutterChange", numhl = "GitGutterChange", text = "~" },
  },
  numhl = true,
  preview_config = {
    border = "rounded",
  },
})
vim.api.nvim_set_keymap("n", "]c", [[<cmd>Gitsigns next_hunk<CR>]], { noremap = true })
vim.api.nvim_set_keymap("n", "[c", [[<cmd>Gitsigns prev_hunk<CR>]], { noremap = true })

A nvim/lua/configs/hop.lua => nvim/lua/configs/hop.lua +60 -0
@@ 0,0 1,60 @@
-- hop.nvim

local ok, hop = pcall(require, "hop")
if not ok then
  return
end

hop.setup()
vim.api.nvim_set_keymap(
  "n",
  "<leader>f",
  [[<cmd>lua require('hop').hint_char1({direction = require('hop.hint').HintDirection.AFTER_CURSOR})<CR>]],
  {}
)
vim.api.nvim_set_keymap(
  "n",
  "<leader>F",
  [[<cmd>lua require('hop').hint_char1({direction = require('hop.hint').HintDirection.BEFORE_CURSOR})<CR>]],
  {}
)
-- luacheck: no max line length
vim.api.nvim_set_keymap(
  "v",
  "<leader>f",
  [[<cmd>lua require('hop').hint_char1({direction = require('hop.hint').HintDirection.AFTER_CURSOR, inclusive_jump = true})<CR>]],
  {}
)
-- luacheck: no max line length
vim.api.nvim_set_keymap(
  "v",
  "<leader>F",
  [[<cmd>lua require('hop').hint_char1({direction = require('hop.hint').HintDirection.BEFORE_CURSOR, inclusive_jump = true})<CR>]],
  {}
)
vim.api.nvim_set_keymap(
  "n",
  "<leader>j",
  [[<cmd>lua require('hop').hint_lines({direction = require('hop.hint').HintDirection.AFTER_CURSOR})<CR>]],
  {}
)
vim.api.nvim_set_keymap(
  "n",
  "<leader>k",
  [[<cmd>lua require('hop').hint_lines({direction = require('hop.hint').HintDirection.BEFORE_CURSOR})<CR>]],
  {}
)
-- luacheck: no max line length
vim.api.nvim_set_keymap(
  "v",
  "<leader>j",
  [[<cmd>lua require('hop').hint_lines({direction = require('hop.hint').HintDirection.AFTER_CURSOR, inclusive_jump = true})<CR>]],
  {}
)
-- luacheck: no max line length
vim.api.nvim_set_keymap(
  "v",
  "<leader>k",
  [[<cmd>lua require('hop').hint_lines({direction = require('hop.hint').HintDirection.BEFORE_CURSOR, inclusive_jump = true})<CR>]],
  {}
)

A nvim/lua/configs/indent-blankline.lua => nvim/lua/configs/indent-blankline.lua +14 -0
@@ 0,0 1,14 @@
-- indent-blankline.nvim

local ok, indent_blankline = pcall(require, "indent_blankline")
if not ok then
  return
end

indent_blankline.setup({
  space_char_blankline = " ",
  show_current_context = true,
  show_current_context_start = true,
  use_treesitter = true,
  buftype_exclude = { "terminal", "nofile" },
})

A nvim/lua/configs/keybindings.lua => nvim/lua/configs/keybindings.lua +29 -0
@@ 0,0 1,29 @@
-- common keybindings for active lsp servers
local _M = {}

local opts = { noremap = true, silent = true }
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)

-- common keybindings for active lsp servers
_M.lsp_keybindings = function(client, bufnr)
  local bufopts = { noremap = true, silent = true, buffer = bufnr }

  vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
  vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
  vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)
  vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts)
  vim.keymap.set("n", "<leader>s", vim.lsp.buf.signature_help, bufopts)
  vim.keymap.set("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, bufopts)
  vim.keymap.set("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, bufopts)
  vim.keymap.set("n", "<leader>wl", function()
    print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
  end, bufopts)
  vim.keymap.set("n", "<leader>T", vim.lsp.buf.type_definition, bufopts)
  vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, bufopts)
  vim.keymap.set("n", "<leader>P", function()
    vim.lsp.buf.format({ async = true })
  end, bufopts)
end

return _M

A nvim/lua/configs/lualine.lua => nvim/lua/configs/lualine.lua +17 -0
@@ 0,0 1,17 @@
-- setup lualine.nvim

local ok, lualine = pcall(require, "lualine")
if not ok then
  return
end

lualine.setup({
  options = {
    theme = "auto",
  },
  tabline = {
    lualine_a = { "buffers" },
    lualine_b = { "filename" },
    lualine_z = { "tabs" },
  },
})

A nvim/lua/configs/nvim-autopairs.lua => nvim/lua/configs/nvim-autopairs.lua +18 -0
@@ 0,0 1,18 @@
-- nvim-autopairs

local ok, autopairs = pcall(require, "nvim-autopairs")
if not ok then
  return
end
local ok, cmp = pcall(require, "cmp")
if not ok then
  return
end

autopairs.setup({
  check_ts = true,
  enable_check_bracket_line = false,
})

local cmp_autopairs = require("nvim-autopairs.completion.cmp")
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))

A nvim/lua/configs/nvim-cmp.lua => nvim/lua/configs/nvim-cmp.lua +78 -0
@@ 0,0 1,78 @@
-- setup nvim-cmp and luasnip

local ok, cmp = pcall(require, "cmp")
if not ok then
  return
end
local ok, luasnip = pcall(require, "luasnip")
if not ok then
  return
end

cmp.setup({
  snippet = {
    expand = function(args)
      luasnip.lsp_expand(args.body)
    end,
  },
  window = {
    completion = cmp.config.window.bordered(),
    documentation = cmp.config.window.bordered(),
  },
  mapping = cmp.mapping.preset.insert({
    ["<C-b>"] = cmp.mapping.scroll_docs(-4),
    ["<C-f>"] = cmp.mapping.scroll_docs(4),
    ["<C-Space>"] = cmp.mapping.complete(),
    ["<C-e>"] = cmp.mapping.abort(),
    ["<CR>"] = cmp.mapping.confirm({
      behavior = cmp.ConfirmBehavior.Replace,
      select = true,
    }),
    ["<Tab>"] = cmp.mapping(function(fallback)
      if cmp.visible() then
        cmp.select_next_item()
      elseif luasnip.expand_or_jumpable() then
        luasnip.expand_or_jump()
      else
        fallback()
      end
    end, { "i", "s" }),
    ["<S-Tab>"] = cmp.mapping(function(fallback)
      if cmp.visible() then
        cmp.select_prev_item()
      elseif luasnip.jumpable(-1) then
        luasnip.jump(-1)
      else
        fallback()
      end
    end, { "i", "s" }),
  }),
  sources = cmp.config.sources({
    { name = "nvim_lsp" },
    { name = "luasnip" },
    { name = "nvim_lsp_signature_help" },
    { name = "buffer" },
    { name = "path", options = {
      trigger_characters = { "/" },
    } },
  }),
})

-- setup buffer source for '/'
cmp.setup.cmdline("/", {
  sources = {
    { name = "buffer" },
  },
  mapping = cmp.mapping.preset.cmdline(),
})

-- setup cmp-path and cmp-cmdline for ':'
cmp.setup.cmdline(":", {
  sources = {
    { name = "cmdline" },
    { name = "path" },
  },
  mapping = cmp.mapping.preset.cmdline(),
})

require("luasnip.loaders.from_vscode").lazy_load()

A nvim/lua/configs/nvim-lspconfig.lua => nvim/lua/configs/nvim-lspconfig.lua +10 -0
@@ 0,0 1,10 @@
-- nvim-lspconfig

local ok, lspconfig_ui = pcall(require, "lspconfig.ui.windows")
if not ok then
  return
end

lspconfig_ui.default_options = {
  border = "rounded",
}

A nvim/lua/configs/nvim-treesitter.lua => nvim/lua/configs/nvim-treesitter.lua +45 -0
@@ 0,0 1,45 @@
-- setup nvim-treesitter and nvim-treesitter-context

local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if not ok then
  return
end
local ok, tscontext = pcall(require, "treesitter-context")
if not ok then
  return
end

treesitter.setup({
  highlight = {
    enable = true,
  },
  -- XXX https://github.com/nvim-lua/kickstart.nvim/blob/af239a5b8182f8aca36a62f3c88279e031edef56/init.lua#L151
  incremental_selection = {
    enable = true,
    keymaps = {
      -- TODO inc/dec?
      init_selection = "gni",
    },
  },
  indent = {
    enable = true,
  },
  refactor = {
    highlight_definitions = { enable = true },
    highlight_current_scope = { enable = false },
    smart_rename = { enable = true },
    -- TODO maybe not so much useful?
    navigation = {
      enable = true,
      keymaps = {
        goto_next_usage = "gnn",
        goto_previous_usage = "gnp",
      },
    },
  },
})

tscontext.setup({
  -- toggle with :TSContextToggle (or add a keymap)
  enable = false,
})

A nvim/lua/configs/telescope.lua => nvim/lua/configs/telescope.lua +108 -0
@@ 0,0 1,108 @@
-- nvim-telescope/telescope.nvim

local ok, telescope = pcall(require, "telescope")
if not ok then
  return
end
local ok, _ = pcall(require, "luasnip")
if not ok then
  return
end

telescope.setup({
  defaults = {
    mappings = {
      i = {
        ["<C-x>"] = false,
        ["<C-s>"] = "select_horizontal",
        ["<ESC>"] = require("telescope.actions").close,
      },
    },
  },
  extensions = {
    fzf = {
      fuzzy = true,
      override_generic_sorter = true,
      override_file_sorter = true,
    },
  },
  pickers = {
    grep_string = {
      theme = "ivy",
    },
    find_files = {
      hidden = true,
    },
    buffers = {
      previewer = false,
      sort_mru = true,
      show_all_buffers = false,
      ignore_current_buffer = true,
      layout_config = {
        width = 0.5,
        height = 0.5,
      },
    },
    current_buffer_fuzzy_find = {
      theme = "ivy",
    },
    live_grep = {
      theme = "ivy",
    },
    diagnostics = {
      theme = "ivy",
    },
  },
})

telescope.load_extension("fzf")

-- cursor on word
vim.api.nvim_set_keymap(
  "n",
  "<leader>*",
  [[<cmd>lua require('telescope.builtin').grep_string()<CR>]],
  { noremap = true }
)
vim.api.nvim_set_keymap(
  "n",
  "<leader>i",
  [[<cmd>lua require('telescope.builtin').find_files()<CR>]],
  { noremap = true }
)
vim.api.nvim_set_keymap("n", "<leader>b", [[<cmd>lua require('telescope.builtin').buffers()<CR>]], { noremap = true })
vim.api.nvim_set_keymap(
  "n",
  "<leader>/",
  [[<cmd>lua require('telescope.builtin').current_buffer_fuzzy_find()<CR>]],
  { noremap = true }
)
vim.api.nvim_set_keymap("n", "<leader>?", [[<cmd>lua require('telescope.builtin').live_grep()<CR>]], { noremap = true })
vim.api.nvim_set_keymap(
  "n",
  "<leader>o",
  [[<cmd>lua require('telescope.builtin').treesitter()<CR>]],
  { noremap = true }
)
vim.api.nvim_set_keymap("n", "<leader>g", [[<cmd>lua require('telescope.builtin').git_files()<CR>]], { noremap = true })
-- diagnostics on current buffer
vim.api.nvim_set_keymap(
  "n",
  "<leader>d",
  [[<cmd>lua require('telescope.builtin').diagnostics({bufnr = 0})<CR>]],
  { noremap = true }
)
-- diagnostics on all buffers
vim.api.nvim_set_keymap(
  "n",
  "<leader>D",
  [[<cmd>lua require('telescope.builtin').diagnostics()<CR>]],
  { noremap = true }
)
-- cursor on word
vim.api.nvim_set_keymap(
  "n",
  "<leader>lr",
  [[<cmd>lua require('telescope.builtin').lsp_references()<CR>]],
  { noremap = true }
)

A nvim/lua/configs/tmux.lua => nvim/lua/configs/tmux.lua +17 -0
@@ 0,0 1,17 @@
-- tmux.nvim

local ok, tmux = pcall(require, "tmux")
if not ok then
  return
end

tmux.setup({
  copy_sync = {
    enable = true,
    redirect_to_clipboard = true,
  },
  navigation = {
    enable_default_keybindings = true,
    persist_zoom = true,
  },
})

A nvim/lua/plugins.lua => nvim/lua/plugins.lua +156 -0
@@ 0,0 1,156 @@
-- bootstrap packer.nvim
local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
local packer_bootstrap = nil
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
  packer_bootstrap = vim.fn.execute("!git clone --depth 1 https://github.com/wbthomason/packer.nvim " .. install_path)
  -- https://github.com/wbthomason/packer.nvim/issues/750
  vim.cmd("packadd packer.nvim")
end

-- run :PackerCompile whenever this file is updated
vim.cmd([[
  augroup packer_user_config
    autocmd!
    autocmd BufWritePost plugins.lua source <afile> | PackerCompile
  augroup end
]])

-- plugins \o/
local packer = require("packer")
packer.startup({
  function(use)
    -- packer.nvim itself
    use("wbthomason/packer.nvim")

    -- LSP things
    -- XXX https://github.com/nvim-lua/kickstart.nvim/blob/af239a5b8182f8aca36a62f3c88279e031edef56/init.lua#L204
    use({
      "neovim/nvim-lspconfig",
      config = function()
        require("configs.nvim-lspconfig")
      end,
    })

    -- completion
    use({
      "hrsh7th/nvim-cmp",
      requires = {
        "hrsh7th/cmp-nvim-lsp",
        "hrsh7th/cmp-buffer",
        "hrsh7th/cmp-path",
        "hrsh7th/cmp-cmdline",
        "saadparwaiz1/cmp_luasnip",
        "L3MON4D3/LuaSnip",
        "rafamadriz/friendly-snippets",
        "hrsh7th/cmp-nvim-lsp-signature-help",
      },
      config = function()
        require("configs.nvim-cmp")
      end,
    })

    -- parsing and highlight
    use({
      "nvim-treesitter/nvim-treesitter",
      requires = {
        "nvim-treesitter/nvim-treesitter-refactor",
        "nvim-treesitter/nvim-treesitter-context",
      },
      run = ":TSUpdate",
      config = function()
        require("configs.nvim-treesitter")
      end,
    })

    -- statusline and tabline
    use({
      "nvim-lualine/lualine.nvim",
      requires = "kyazdani42/nvim-web-devicons",
      config = function()
        require("configs.lualine")
      end,
    })

    -- git stuff
    use({
      "lewis6991/gitsigns.nvim",
      requires = "nvim-lua/plenary.nvim",
      config = function()
        require("configs.gitsigns")
      end,
    })

    -- tmux integration (navigation, copy, ...)
    use({
      "aserowy/tmux.nvim",
      config = function()
        require("configs.tmux")
      end,
    })

    -- moving around
    use({
      "phaazon/hop.nvim",
      config = function()
        require("configs.hop")
      end,
    })

    -- autopair
    use({
      "windwp/nvim-autopairs",
      config = function()
        require("configs.nvim-autopairs")
      end,
    })

    -- indentation
    use({
      "lukas-reineke/indent-blankline.nvim",
      config = function()
        require("configs.indent-blankline")
      end,
    })

    -- misc
    use({
      "nvim-telescope/telescope.nvim",
      requires = {
        { "nvim-lua/plenary.nvim" },
        { "nvim-telescope/telescope-fzf-native.nvim", run = "make" },
      },
      config = function()
        require("configs.telescope")
      end,
    })

    -- comment
    use({
      "numToStr/Comment.nvim",
      config = function()
        require("configs.Comment")
      end,
    })

    -- theme
    use({
      "RRethy/nvim-base16",
      config = function()
        require("configs.colors")
      end,
    })

    -- bootstraping
    if packer_bootstrap then
      packer.sync()
    end
  end,
  config = {
    display = {
      open_fn = function()
        return require("packer.util").float({ border = "rounded" })
      end,
      prompt_border = "rounded",
    },
  },
})