2023-02-18 17:59:03 +01:00
|
|
|
|
-- luacheck: globals vim
|
|
|
|
|
|
|
|
|
|
require("packer").startup(function(use)
|
|
|
|
|
use("tpope/vim-sensible")
|
|
|
|
|
|
|
|
|
|
use("vimwiki/vimwiki")
|
|
|
|
|
use("freitass/todo.txt-vim")
|
|
|
|
|
use("ledger/vim-ledger")
|
|
|
|
|
|
|
|
|
|
use("Shougo/deoplete.nvim")
|
|
|
|
|
use("dense-analysis/ale")
|
|
|
|
|
|
|
|
|
|
use("psliwka/vim-smoothie")
|
|
|
|
|
|
|
|
|
|
-- navigation
|
|
|
|
|
use("easymotion/vim-easymotion")
|
|
|
|
|
use("tpope/vim-unimpaired")
|
|
|
|
|
use("tpope/vim-surround")
|
|
|
|
|
use("christoomey/vim-tmux-navigator")
|
|
|
|
|
|
|
|
|
|
-- fern
|
|
|
|
|
use("lambdalisue/fern.vim")
|
|
|
|
|
use("lambdalisue/nerdfont.vim")
|
|
|
|
|
use("lambdalisue/fern-renderer-nerdfont.vim")
|
|
|
|
|
use("lambdalisue/glyph-palette.vim")
|
|
|
|
|
use("lambdalisue/fern-git-status.vim")
|
|
|
|
|
use("lambdalisue/fern-mapping-git.vim") -- to check
|
|
|
|
|
use("lambdalisue/fern-hijack.vim")
|
|
|
|
|
|
|
|
|
|
-- airline
|
|
|
|
|
use("vim-airline/vim-airline")
|
|
|
|
|
use("vim-airline/vim-airline-themes")
|
|
|
|
|
|
|
|
|
|
use("tpope/vim-fugitive")
|
|
|
|
|
use("airblade/vim-gitgutter")
|
|
|
|
|
|
|
|
|
|
use("honza/vim-snippets")
|
|
|
|
|
use("SirVer/ultisnips")
|
|
|
|
|
|
|
|
|
|
use("junegunn/fzf.vim")
|
|
|
|
|
|
|
|
|
|
use("junegunn/goyo.vim")
|
|
|
|
|
use("junegunn/limelight.vim")
|
|
|
|
|
|
|
|
|
|
use("preservim/nerdcommenter")
|
|
|
|
|
|
|
|
|
|
use("luochen1990/rainbow")
|
|
|
|
|
use("ap/vim-css-color")
|
|
|
|
|
|
|
|
|
|
use("Yggdroot/indentLine")
|
|
|
|
|
|
|
|
|
|
use("gruvbox-community/gruvbox")
|
|
|
|
|
|
|
|
|
|
-- language support
|
|
|
|
|
use("darrikonn/vim-gofmt")
|
|
|
|
|
use("Glench/Vim-Jinja2-Syntax")
|
|
|
|
|
use("preservim/vim-markdown")
|
|
|
|
|
use("LnL7/vim-nix")
|
|
|
|
|
use("hashivim/vim-terraform")
|
|
|
|
|
use("LaTeX-Box-Team/LaTeX-Box")
|
|
|
|
|
use("vito-c/jq.vim")
|
|
|
|
|
use("tpope/vim-haml")
|
|
|
|
|
use({ "psf/black", branch = "stable" })
|
|
|
|
|
use("elzr/vim-json")
|
|
|
|
|
use("z0mbix/vim-shfmt")
|
|
|
|
|
use("ckipp01/stylua-nvim")
|
|
|
|
|
|
|
|
|
|
use("jpalardy/vim-slime")
|
|
|
|
|
use("neovim/nvim-lspconfig")
|
|
|
|
|
use("lukas-reineke/lsp-format.nvim")
|
2023-05-26 15:09:46 +02:00
|
|
|
|
|
|
|
|
|
use("sheerun/vim-polyglot")
|
2023-02-18 17:59:03 +01:00
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
local o = vim.opt
|
|
|
|
|
|
|
|
|
|
local function map(mode, shortcut, command)
|
|
|
|
|
vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true })
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function nmap(shortcut, command)
|
|
|
|
|
map("n", shortcut, command)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--local function imap(shortcut, command)
|
|
|
|
|
-- map("i", shortcut, command)
|
|
|
|
|
--end
|
|
|
|
|
|
|
|
|
|
o.wrap = false
|
|
|
|
|
o.number = true
|
|
|
|
|
o.compatible = false
|
|
|
|
|
o.mouse = "a" -- mouse support
|
|
|
|
|
o.showcmd = true -- show incomplete cmds down the bottom
|
|
|
|
|
o.showmode = true -- show current mode
|
|
|
|
|
o.showmatch = true -- set show matching parenthesis
|
|
|
|
|
o.visualbell = true -- no sounds
|
|
|
|
|
o.autoread = true -- reload files changed outside of vim
|
|
|
|
|
o.backspace = [[indent,eol,start]] -- allow backspacing over everything in insert mode
|
|
|
|
|
o.ignorecase = true -- ignore case when searching
|
|
|
|
|
o.shiftround = true -- use multiple of shiftwidth when indenting with '<' and '>'
|
|
|
|
|
o.smartcase = true -- ignore case if searching pattern is all lowecase, case-sensitive otherwise
|
|
|
|
|
o.smarttab = true -- insert tabs on the start of a line according to shiftwidth, not tabstop
|
|
|
|
|
o.hlsearch = true -- highlight search terms
|
|
|
|
|
o.incsearch = true -- show search matches as you type
|
|
|
|
|
o.hidden = true
|
|
|
|
|
o.ruler = true
|
|
|
|
|
o.clipboard = "unnamed" -- system clipboard
|
|
|
|
|
o.colorcolumn = "80"
|
|
|
|
|
|
|
|
|
|
vim.cmd("syntax on")
|
|
|
|
|
vim.cmd("filetype plugin on")
|
|
|
|
|
|
|
|
|
|
if vim.fn.has("multi_byte") == 1 and vim.o.encoding == "utf-8" then
|
|
|
|
|
o.listchars = [[tab:▸ ,extends:❯,precedes:❮,nbsp:±,trail:…]]
|
|
|
|
|
else
|
|
|
|
|
o.listchars = [[tab:> ,extends:>,precedes:<,nbsp:.,trail:_]]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
vim.g.mapleader = ","
|
|
|
|
|
vim.g.maplocaleader = "\\"
|
|
|
|
|
|
|
|
|
|
o.splitbelow = true
|
|
|
|
|
o.splitright = true
|
|
|
|
|
nmap("<A-r>", "<C-w>r")
|
|
|
|
|
|
|
|
|
|
nmap("<A-1>", "1gt")
|
|
|
|
|
nmap("<A-2>", "2gt")
|
|
|
|
|
nmap("<A-3>", "3gt")
|
|
|
|
|
nmap("<A-4>", "4gt")
|
|
|
|
|
nmap("<A-5>", "5gt")
|
|
|
|
|
nmap("<A-6>", "6gt")
|
|
|
|
|
nmap("<A-7>", "7gt")
|
|
|
|
|
nmap("<A-8>", "8gt")
|
|
|
|
|
nmap("<A-9>", ":tablast<cr>")
|
|
|
|
|
|
|
|
|
|
nmap("<C-l>", ":nohl<CR><C-l>")
|
|
|
|
|
|
|
|
|
|
-- todo: try to do it with `vim.api.nvim_set_hl`
|
|
|
|
|
vim.cmd("hi CursorLine cterm=NONE,underline ctermbg=NONE") -- highlight line when in insert mode
|
|
|
|
|
|
|
|
|
|
o.timeoutlen = 1000
|
|
|
|
|
o.ttimeoutlen = 0
|
|
|
|
|
|
|
|
|
|
vim.cmd("autocmd InsertEnter * :set cursorline")
|
|
|
|
|
vim.cmd("autocmd InsertLeave * :set nocursorline")
|
|
|
|
|
|
|
|
|
|
-- indentation
|
|
|
|
|
vim.cmd("filetype indent on")
|
|
|
|
|
o.softtabstop = 4
|
|
|
|
|
o.expandtab = true
|
|
|
|
|
o.shiftwidth = 4
|
|
|
|
|
o.tabstop = 4
|
|
|
|
|
o.autoindent = true
|
|
|
|
|
o.copyindent = true
|
|
|
|
|
|
|
|
|
|
-- folds
|
|
|
|
|
o.foldmethod = "indent"
|
|
|
|
|
o.foldnestmax = 3
|
|
|
|
|
o.foldenable = false
|
|
|
|
|
|
|
|
|
|
o.termguicolors = true
|
|
|
|
|
vim.g.gruvbox_contrast_dark = "hard"
|
|
|
|
|
vim.g.gruvbox_contrast_light = "hard"
|
|
|
|
|
vim.g.gruvbox_italic = 1
|
|
|
|
|
vim.g.gruvbox_invert_indent_guides = 1
|
|
|
|
|
vim.g.gruvbox_vert_split = "bg1"
|
|
|
|
|
vim.cmd("colorscheme gruvbox")
|
|
|
|
|
o.background = "dark"
|
|
|
|
|
|
|
|
|
|
vim.g.markdown_syntax_conceal = 0
|
|
|
|
|
|
|
|
|
|
o.updatetime = 100 -- to make gigutter more responsive
|
|
|
|
|
|
|
|
|
|
vim.g["fern#renderer"] = "nerdfont"
|
|
|
|
|
vim.cmd([[
|
|
|
|
|
function! s:init_fern() abort
|
|
|
|
|
nmap <buffer> T <Plug>(fern-action-open:tab)
|
|
|
|
|
nmap <buffer> S <Plug>(fern-action-open:split)
|
|
|
|
|
nmap <buffer> V <Plug>(fern-action-open:vsplit)
|
|
|
|
|
nmap <buffer> <Space> <Plug>(fern-action-mark:toggle)
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
augroup fern-custom
|
|
|
|
|
autocmd! *
|
|
|
|
|
autocmd FileType fern call s:init_fern()
|
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
augroup my-glyph-palette
|
|
|
|
|
autocmd! *
|
|
|
|
|
autocmd FileType fern call glyph_palette#apply()
|
|
|
|
|
autocmd FileType nerdtree,startify call glyph_palette#apply()
|
|
|
|
|
augroup END
|
|
|
|
|
]])
|
|
|
|
|
nmap("<leader>t", ":Fern . -drawer -toggle<cr>")
|
|
|
|
|
nmap("<leader>f", ":Files<cr>")
|
|
|
|
|
nmap("<leader>rg", ":Rg<cr>")
|
|
|
|
|
nmap("<leader><Bs>", ": cd ..<cr>")
|
|
|
|
|
nmap("<leader>b", ": Buffers<cr>")
|
|
|
|
|
|
|
|
|
|
vim.g["indentLine_char"] = "▏"
|
|
|
|
|
vim.g["indentLine_setConceal"] = 0
|
|
|
|
|
|
|
|
|
|
vim.g["slime_target"] = "tmux"
|
|
|
|
|
vim.g["slime_python_ipython"] = 1
|
|
|
|
|
|
|
|
|
|
vim.g["tmux_navigator_no_mappings"] = 1
|
|
|
|
|
nmap("<A-h>", ":TmuxNavigateLeft<cr>")
|
|
|
|
|
nmap("<A-j>", ":TmuxNavigateDown<cr>")
|
|
|
|
|
nmap("<A-k>", ":TmuxNavigateUp<cr>")
|
|
|
|
|
nmap("<A-l>", ":TmuxNavigateRight<cr>")
|
|
|
|
|
|
|
|
|
|
vim.g["airline_theme"] = "base16_gruvbox_dark_hard"
|
|
|
|
|
vim.g["airline#extensions#tabline#enabled"] = 1
|
|
|
|
|
vim.g["airline#extensions#ale#enabled"] = 1
|
|
|
|
|
|
|
|
|
|
vim.g["ale_lint_on_text_changed"] = "never"
|
|
|
|
|
vim.g["ale_lint_on_insert_leave"] = 0
|
|
|
|
|
vim.g["ale_lint_on_enter"] = 0
|
|
|
|
|
|
|
|
|
|
vim.g["deoplete#enable_at_startup"] = 1
|
|
|
|
|
|
|
|
|
|
-- vim.g["black_virtualenv"] = "/Users/rilla/virtualenvs/black"
|
|
|
|
|
|
|
|
|
|
vim.g["shfmt_extra_args"] = "-i 4"
|
|
|
|
|
vim.g["NERDDefaultAlign"] = "left"
|
|
|
|
|
|
|
|
|
|
vim.g["UltiSnipsExpandTrigger"] = "<tab>"
|
|
|
|
|
vim.g["UltiSnipsJumpForwardTrigger"] = "<c-b>"
|
|
|
|
|
vim.g["UltiSnipsJumpBackwardTrigger"] = "<c-z>"
|
|
|
|
|
|
|
|
|
|
local formatters = {
|
|
|
|
|
go = ":GoFmt<CR>",
|
|
|
|
|
json = ":%!jq --indent 4 .<CR>",
|
|
|
|
|
nix = ":%!nixfmt < %<CR>",
|
|
|
|
|
-- python = ":Black<CR>",
|
|
|
|
|
python = [[<cmd>lua vim.lsp.buf.format()<CR>]],
|
|
|
|
|
sh = ":Shfmt<CR>",
|
|
|
|
|
sql = ":%!sqlfluff fix -<CR>",
|
|
|
|
|
terraform = ":TerraformFmt<CR>",
|
|
|
|
|
lua = [[<cmd>lua require("stylua-nvim").format_file()<CR>]],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for pattern, command in pairs(formatters) do
|
|
|
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
|
|
|
pattern = pattern,
|
|
|
|
|
callback = function()
|
|
|
|
|
nmap("<C-f>", command)
|
|
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
require("lspconfig").pyright.setup({})
|
|
|
|
|
|
|
|
|
|
require("lspconfig").efm.setup({
|
|
|
|
|
init_options = { documentFormatting = true },
|
|
|
|
|
settings = {
|
|
|
|
|
rootMarkers = { ".git/", "pyproject.toml" },
|
|
|
|
|
languages = {
|
|
|
|
|
python = { { formatCommand = "black -", formatStdin = true } },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|