Dotfiles to set up my development environment
Nvim:
~/.config/nvim/init.vim
set path+=**
" Nice menu when typing `:find *.py`
set wildmode=longest,list,full
set wildmenu
" 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 tabstop=4 softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set exrc
set guicursor=
set relativenumber
set nohlsearch
set hidden
set noerrorbells
set nu
set nowrap
set noswapfile
set nobackup
set undodir=~/.vim/undodir
set undofile
set signcolumn=yes
set incsearch
set termguicolors
set scrolloff=8
set signcolumn=yes
set cmdheight=2
set updatetime=50
set shortmess+=c
call plug#begin('~/.vim/plugged')
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' }
Plug 'gruvbox-community/gruvbox'
" Plug 'glepnir/galaxyline.nvim' , {'branch': 'main'}
Plug 'nvim-treesitter/nvim-treesitter'
Plug 'nvim-treesitter/playground'
Plug 'mbbill/undotree'
" Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
" Line
Plug 'itchyny/lightline.vim'
" LSP config
Plug 'neovim/nvim-lspconfig'
" LSP autocomplete
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
" LSP luasnip
Plug 'L3MON4D3/LuaSnip'
Plug 'saadparwaiz1/cmp_luasnip'
" Formater
Plug 'sbdchd/neoformat'
" Surrounder
Plug 'tpope/vim-surround'
" Markdown preview
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
" Harpoon
Plug 'nvim-lua/plenary.nvim'
Plug 'ThePrimeagen/harpoon'
" DAP
Plug 'mfussenegger/nvim-dap'
Plug 'leoluz/nvim-dap-go'
Plug 'rcarriga/nvim-dap-ui'
Plug 'theHamsta/nvim-dap-virtual-text'
call plug#end()
colorscheme gruvbox
lua << EOF
require'lsp'
EOF
lua << EOF
require'dapconfig'
EOF
if executable('rg')
let g:rg_derive_root='true'
endif
let loaded_matchparen = 1
" let g:deoplete#enable_at_startup = 1
let mapleader = " "
nnoremap <leader>ps :lua require('telescope.builtin').grep_string({search=vim.fn.input("Grep For > ")})<CR>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>td <cmd>Telescope diagnostics<cr>
" nnoremap <leader>h :wincmd h<CR>
" nnoremap <leader>j :wincmd j<CR>
" nnoremap <leader>k :wincmd k<CR>
" nnoremap <leader>l :wincmd l<CR>
nnoremap <leader>pv :wincmd v<bar> :Ex <bar> :vertical resize 30<CR>
nnoremap <silent> <leader>+ :vertical resize +5<CR>
nnoremap <silent> <leader>- :vertical resize -5<CR>
nnoremap <silent> <leader>u :UndotreeShow<CR>
" Harpoon
nnoremap <leader>ha :lua require("harpoon.mark").add_file()<CR>
nnoremap <leader>hl :lua require("harpoon.ui").toggle_quick_menu()<CR>
nnoremap <leader>hn :lua require("harpoon.ui").nav_next()<CR>
nnoremap <leader>hp :lua require("harpoon.ui").nav_prev()<CR>
nnoremap <leader>ht :lua require("telescope").load_extension('harpoon')<CR><cmd>Telescope harpoon marks<CR>
" Quick list
nnoremap <leader>qo :copen<CR>
nnoremap <leader>qc :cclose<CR>
nnoremap <leader>qp :cprev<CR>
nnoremap <leader>qn :cnext<CR>
function! QuickfixMapping()
" Go to the previous location and stay in the quickfix window
nnoremap <buffer> K :cprev<CR>zz<C-w>w
" Go to the next location and stay in the quickfix window
nnoremap <buffer> J :cnext<CR>zz<C-w>w
" Make the quickfix list modifiable
nnoremap <buffer> <leader>u :set modifiable<CR>
" Save the changes in the quickfix window
nnoremap <buffer> <leader>w :cgetbuffer<CR>:cclose<CR>:copen<CR>
" Begin the search and replace
nnoremap <buffer> <leader>r :cdo s/// \| update<C-Left><C-Left><Left><Left><Left>
endfunction
augroup quickfix_group
autocmd!
" Use custom keybindings
autocmd filetype qf call QuickfixMapping()
" Add the errorformat to be able to update the quickfix list
autocmd filetype qf setlocal errorformat+=%f\|%l\ col\ %c\|%m
augroup END
fun! TrimWhitespace()
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
endfun
augroup HANCHON
autocmd!
autocmd BufWritePre * : call TrimWhitespace()
augroup END
autocmd FileType TelescopePrompt
\ call deoplete#custom#buffer_option('auto_complete', v:false)
filetype plugin indent on
augroup fmt
autocmd!
autocmd BufWritePre * undojoin | Neoformat
augroup end
let g:neoformat_python_autopep8 = {
\ 'exe': 'autopep8',
\ 'args': ['-s 4', '-E'],
\ 'replace': 1,
\ 'stdin': 1,
\ 'env': ["DEBUG=1"],
\ 'valid_exit_codes': [0, 23],
\ 'no_append': 1,
\ }
let g:neoformat_enabled_python = ['yapf']
set autowrite
" Go syntax highlighting
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_operators = 1
Bash
~/.config/nvim/lua/lsp.lua
-- LSP
-- Setup lspconfig.
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
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', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<space>f', vim.lsp.buf.formatting, bufopts)
vim.keymap.set('n', '<leader>df', vim.diagnostic.goto_next, { buffer = 0 })
vim.keymap.set('n', '<leader>dp', vim.diagnostic.goto_prev, { buffer = 0 })
vim.keymap.set('n', '<leader>dl', '<cmd>Telescope diagnostics<cr>', { buffer = 0 })
end
require'lspconfig'.pyright.setup{
on_attach = on_attach,
capabilities = capabilities,
}
require('lspconfig').gopls.setup{
on_attach = on_attach,
capabilities = capabilities,
}
require('lspconfig').tsserver.setup{
on_attach = on_attach,
capabilities = capabilities,
}
vim.opt.completeopt={'menu', 'menuone', 'noselect'}
-- Setup nvim-cmp.
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
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({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' }, -- For luasnip users.
}, {
{ name = 'buffer' },
})
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
Lua
~/.config/nvim/lua/dapconfig.lua
-- DAP
vim.keymap.set('n', '<space>1', ":lua require'dap'.continue()<CR>")
vim.keymap.set('n', '<space>2', ":lua require'dap'.step_over()<CR>")
vim.keymap.set('n', '<space>3', ":lua require'dap'.step_into()<CR>")
vim.keymap.set('n', '<space>4', ":lua require'dap'.step_out()<CR>")
vim.keymap.set('n', '<space>b', ":lua require'dap'.toggle_breakpoint()<CR>")
vim.keymap.set('n', '<space>B', ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>")
vim.keymap.set('n', '<space>lp', ":lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>")
vim.keymap.set('n', '<space>dr', ":lua require'dap'.repl.open()<CR>")
require('nvim-dap-virtual-text').setup()
require('dap-go').setup()
require("dapui").setup()
local dap, dapui = require("dap"), require("dapui")
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open()
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close()
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
end
Lua
Tmux
~/.tmux.conf
set -ga terminal-overrides ",xterm-256color*:Tc"
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
set -g status-style 'bg=#333333 fg=#5eacd3'
bind r source-file ~/.tmux.conf
set -g base-index 1
set-option -sg escape-time 10
set-option -g focus-events on
set-option -g default-terminal "screen-256color"
# set-window-option -g mode-keys vi
# bind -T copy-mode-vi v send-keys -X begin-selection
# bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
set-window-option -g xterm-keys on
# vim-like pane switching
bind -r ^ last-window
bind -r k select-pane -U
bind -r j select-pane -D
bind -r h select-pane -L
bind -r l select-pane -R
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'dracula/tmux'
set -g @dracula-show-fahrenheit false
set -g @dracula-plugins "git battery ram-usage cpu-usage network time"
set -g @dracula-border-contrast true
set -g @dracula-military-time true
set -g @dracula-day-month true
run '~/.tmux/plugins/tpm/tpm'
Bash
Additional dependencies:
iterm2