moved neovim config to lua and manage plugins with packer

feat/kile-v2
Ricard Illa 2023-02-18 17:59:03 +01:00
parent 0610a9e61f
commit c5fc5bc9bf
No known key found for this signature in database
GPG Key ID: F69A672B72E54902
4 changed files with 272 additions and 390 deletions

View File

@ -9,167 +9,18 @@
withPython3 = true;
extraPackages = with pkgs; [
black
jq
# sqlfluff
nixfmt
shfmt
efm-langserver
hlint
pylint
jq
lua54Packages.luacheck
nixfmt
nodePackages.pyright
pylint
shfmt
stylua
];
extraPython3Packages = pyPkgs: with pyPkgs; [ pylint ];
plugins = with pkgs.vimPlugins;
# find sha256 with:
# nix-prefetch-url --unpack https://github.com/${owner}/${repo}/archive/${rev}.tar.gz
let
nerdfont-vim = pkgs.vimUtils.buildVimPlugin {
pname = "nerdfont-vim";
version = "git";
src = pkgs.fetchFromGitHub {
owner = "lambdalisue";
repo = "nerdfont.vim";
rev = "5f484cf638ca31fc9db95b33b92bf5aa4b2d1270";
sha256 = "01lfqlsbs1192v0kydz98qypbvl6h3vkjjj5cl6zcadq52macl5s";
};
meta.homepage = "https://github.com/lambdalisue/nerdfont.vim";
};
fern-renderer-nerdfont = pkgs.vimUtils.buildVimPlugin {
pname = "fern-renderer-nerdfont";
version = "git";
src = pkgs.fetchFromGitHub {
owner = "lambdalisue";
repo = "fern-renderer-nerdfont.vim";
rev = "942be10bda577ba4840c4a939200f05024b8603c";
sha256 = "0nz5ycs9r9w0in3jjmcm121ik3jggj4mj3r88fmk8bw1jwl1hffm";
};
meta.homepage =
"https://github.com/lambdalisue/fern-renderer-nerdfont.vim";
};
glyph-palette = pkgs.vimUtils.buildVimPlugin {
pname = "glyph-palette";
version = "git";
src = pkgs.fetchFromGitHub {
owner = "lambdalisue";
repo = "glyph-palette.vim";
rev = "a8ecb59733d8b4a2f45fdbcabf5174fdee18c4ec";
sha256 = "0pzlwiyvrp994f5d9sw2vymdi1s5x7ywvwm0n4vmv3i9q9yyhxja";
};
meta.homepage =
"https://github.com/lambdalisue/fern-renderer-nerdfont.vim";
};
fern-git-status = pkgs.vimUtils.buildVimPlugin {
pname = "fern-git-status";
version = "git";
src = pkgs.fetchFromGitHub {
owner = "lambdalisue";
repo = "fern-git-status.vim";
rev = "151336335d3b6975153dad77e60049ca7111da8e";
sha256 = "1iqd035psn953v162didqd72cb7f0n7w34c2qsf15qkyq3y97pzl";
};
meta.homepage = "https://github.com/lambdalisue/fern-git-status.vim";
};
fern-mapping-git = pkgs.vimUtils.buildVimPlugin {
pname = "fern-mapping-git";
version = "git";
src = pkgs.fetchFromGitHub {
owner = "lambdalisue";
repo = "fern-mapping-git.vim";
rev = "df5e7466df8596c95dd355d49a72893018919cf1";
sha256 = "1lhppbydg9wlc520042k6bqvwblvmr7xx0w44s2xwbwbffj6hjz3";
};
meta.homepage = "https://github.com/lambdalisue/fern-mapping-git.vim";
};
fern-hijack = pkgs.vimUtils.buildVimPlugin {
pname = "fern-hijack";
version = "git";
src = pkgs.fetchFromGitHub {
owner = "lambdalisue";
repo = "fern-hijack.vim";
rev = "24daa61d69b878947946e84a7711f8b58eae0f50";
sha256 = "1z8zracqk52rar6wra7n1hlvfa1xqks1x0np7rs1aq9g7d02d6wg";
};
meta.homepage = "https://github.com/lambdalisue/fern-hijack.vim";
};
black-vim = pkgs.vimUtils.buildVimPlugin rec {
pname = "black-vim";
version = "23.1.0";
src = pkgs.fetchFromGitHub {
owner = "psf";
repo = "black";
rev = "refs/tags/${version}";
sha256 = "08rvk15mrvpmmjw7zw1ixcgh3sx2knadzrpp21q8kamvbizbjp5f";
};
meta.homepage = "https://github.com/psf/black";
};
vim-tidal = pkgs.vimUtils.buildVimPlugin {
pname = "vim-tidal";
version = "git";
src = pkgs.fetchFromGitHub {
owner = "tidalcycles";
repo = "vim-tidal";
rev = "7962ed7586db8f83fb02e89d60d1014c54719dd0";
sha256 = "0krjn9zqcdnd5f4189djp4gbmsx0qf8hwlhfp9cd5xq19r8z3faw";
};
buildPhase = "# do nothing";
};
scvim = pkgs.vimUtils.buildVimPlugin {
pname = "scvim";
version = "git";
src = pkgs.fetchFromGitHub {
owner = "supercollider";
repo = "scvim";
rev = "4b738f8a13056e0a74227135ff928c0149d233eb";
sha256 = "12ap94ygf9hv03ffcqa44l6h0gf714dx33yqkl6h06r834iff6ab";
};
meta.homepage = "https://github.com/psf/black";
};
in [ # nix-env -f '<nixpkgs>' -qaP -A vimPlugins
FixCursorHold-nvim
airline
ale
csv
deoplete-nvim
easymotion
fern-vim
fugitive
fzf-vim
gitgutter
goyo
gruvbox-community
indentLine
limelight-vim
neoformat
neomake
nerdcommenter
rainbow
sensible
tmux-navigator
todo-txt-vim
ultisnips
vim-airline-themes
vim-css-color
vim-jinja
vim-ledger
vim-markdown
vim-nix
vim-slime
vim-smoothie
vim-snippets
vim-terraform
vim-unimpaired
vimwiki
nerdfont-vim
fern-renderer-nerdfont
glyph-palette
fern-git-status
fern-mapping-git
fern-hijack
black-vim
vim-tidal
scvim
];
extraConfig = builtins.readFile ./init.vim;
plugins = [ pkgs.vimPlugins.packer-nvim ];
extraLuaConfig = builtins.readFile ./init.lua;
};
}

260
home/neovim/init.lua Normal file
View File

@ -0,0 +1,260 @@
-- 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")
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 } },
},
},
})

View File

@ -1,231 +0,0 @@
set nowrap
set nocompatible
syntax enable
filetype plugin on
set number
set mouse=a " mouse support
set showcmd " show incomplete cmds down the bottom
set showmode " show current mode
set visualbell " no sounds
set autoread " reload files changed outside vim
"set gcr=a:blinkon0 " disable cursor blink
set backspace=indent,eol,start " allow backspacing over everything in insert
mode
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set showmatch " set show matching parenthesis
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase, case-sensitive otherwise
set smarttab " insert tabs on the start of a line according to shiftwidth, not tabstop
set hlsearch " highlight search terms
set incsearch " show search matches as you type
set hidden
set ruler
set clipboard=unnamed " system clipboard
set list listchars=tab:\ \ ,trail" display tabs and trailing spaces visually
set colorcolumn=80
set splitbelow
set splitright
nmap <A-r> <C-w>r
let mapleader=","
let maplocalleader="\\"
" use alt-x to go to a specific tab
nnoremap <A-1> 1gt
nnoremap <A-2> 2gt
nnoremap <A-3> 3gt
nnoremap <A-4> 4gt
nnoremap <A-5> 5gt
nnoremap <A-6> 6gt
nnoremap <A-7> 7gt
nnoremap <A-8> 8gt
nnoremap <A-9> :tablast<cr>
" clean highlights when C-l
nnoremap <silent> <C-l> :nohl<CR><C-l>
" HIGHLIGHT LINE WHEN IN INSERT MODE
hi CursorLine cterm=NONE,underline ctermbg=NONE
set timeoutlen=1000 ttimeoutlen=0 " eliminate annoying delay
autocmd InsertEnter * :set cursorline
autocmd InsertLeave * :set nocursorline
" INDENTATION:
filetype indent on
set softtabstop=4
set expandtab
set shiftwidth=4 " number of spaces to use for autoindenting
set tabstop=4 " a tab is four spaces
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
" TAG JUMPING:
command! MakeTags !ctags -R .
" - ^] to jump to tag under cursor
" - g^] for ambiguous tags
" - ^t to jump back up the tag stack
" TURN OF SWAP FILES:
set noswapfile
set nobackup
set nowb
"FOLDS:
set foldmethod=indent " fold based on indent
set foldnestmax=3 " deepest fold is 3 levels
set nofoldenable " don't fold by default
" FINDING FILES:
set path+=**
set wildmenu
" - Hit tab to find for partial match
" - Use * to make it fuzzy
let g:markdown_syntax_conceal = 0
set updatetime=100 " reduce vim update time so magke gitgutter more responsive
set termguicolors
"set fillchars+=vert:\ " cleaner vertical line
"let g:gruvbox_contrast_dark="hard"
"let g:gruvbox_contrast_light="hard"
"let g:gruvbox_italic=1
"let g:gruvbox_invert_indent_guides=1
"let g:gruvbox_vert_split='bg1'
let g:gruvbox_contrast_dark="hard"
set background=dark
colorscheme gruvbox
let g:fern#renderer = "nerdfont"
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)
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
nnoremap <leader>t :Fern . -drawer -toggle<cr>
nnoremap <leader>f :Files<cr>
nnoremap <leader>rg :Rg<cr>
nnoremap <leader><Bs> :cd ..<cr>
nnoremap <Leader>b :Buffers<cr>
"let g:NERDTreeIndicatorMapCustom = {
"\ "Modified" : "✹",
"\ "Staged" : "✚",
"\ "Untracked" : "✭",
"\ "Renamed" : "➜",
"\ "Unmerged" : "═",
"\ "Deleted" : "✖",
"\ "Dirty" : "✗",
"\ "Clean" : "✔︎",
"\ 'Ignored' : '☒',
"\ "Unknown" : "?"
"\ }
let g:indentLine_char = '▏'
"let g:indentLine_color_term = 2854
let g:indentLine_setConceal = 0
"let g:indentLine_concealcursor=""
let g:slime_target="tmux"
let g:slime_python_ipython=1
let g:tmux_navigator_no_mappings = 1
nnoremap <silent> <A-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <A-j> :TmuxNavigateDown<cr>
nnoremap <silent> <A-k> :TmuxNavigateUp<cr>
nnoremap <silent> <A-l> :TmuxNavigateRight<cr>
"let g:lightline = {'colorscheme': 'gruvbox'}
let g:limelight_conceal_ctermfg = 'DarkGray'
" let g:vim_json_syntax_conceal = 0
let g:airline_theme='base16_gruvbox_dark_hard'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:ale_linters ={
\ 'haskell': ['hlint', 'hdevtools', 'hfmt'],
\}
" let g:ale_python_auto_pipenv=1 " see ale-integrations-local-executables
"let g:ale_python_pylint_auto_pipenv=1
" let g:ale_python_pylint_executable="pipenv"
let g:ale_python_pylint_change_directory=1
autocmd! User GoyoEnter Limelight
autocmd! User GoyoLeave Limelight!!
" function LoadBraces (except)
" if (&ft != a:except)
" RainbowParenthesesLoadBraces
" endif
" endfunction
"
" " For rainbow parenhteses
" au VimEnter * RainbowParenthesesToggle
" au Syntax * RainbowParenthesesLoadRound
" au Syntax * RainbowParenthesesLoadSquare
" au Syntax * call LoadBraces('haskell')
"autocmd! BufWritePost,BufEnter * Neomake
let g:deoplete#enable_at_startup = 1
let g:rainbow_active = 1
let g:black_linelength=79
let g:NERDDefaultAlign = 'left'
nnoremap <silent> <F6> i
inoremap <silent> <F6> <Nop>
nnoremap <silent> <F18> a
inoremap <silent> <F18> <Nop>
nnoremap <leader>p "=system('xsel')<cr>p
nnoremap <leader>m :!make<cr>
" CLOJURE
let g:clj_fmt_autosave = 0
"autocmd FileType clojure nnoremap <c-t> :hi Normal ctermbg=none<cr>
autocmd FileType clojure nnoremap <F5> :Eval<cr>
autocmd FileType clojure vnoremap <F5> :Eval<cr>
autocmd FileType clojure nnoremap <F12> :Eval (stop)<cr>
autocmd FileType clojure nnoremap <c-f> :Cljfmt<cr>
"set formatoptions+=w
"set tw=80
"nnoremap Q gqip
" au BufNewFile,BufRead *.go setlocal noet ts=4 sw=4 sts=4
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
autocmd FileType sql nnoremap <buffer> <C-f> :%!sqlfluff fix -<CR>
autocmd FileType sh nnoremap <buffer> <C-f> :Shfmt<CR>
autocmd FileType json nnoremap <buffer> <C-f> :%!jq --indent 4 .<CR>
autocmd FileType terraform nnoremap <buffer> <C-f> :TerraformFmt<CR>
autocmd FileType nix nnoremap <buffer> <C-f> :%!nixfmt < %<CR>
" autocmd FileType python nnoremap <buffer> <C-f> :Black<CR>
autocmd FileType python nnoremap <buffer> <C-f> :!black %<CR>

View File

@ -55,6 +55,7 @@
./browsers
./cheat
./dav
./drawterm
./fonts
./git
./gotify
@ -119,6 +120,7 @@
".config/chromium"
".config/kdeconnect"
".config/kicad"
".config/nvim/plugin"
".config/syncthing"
".config/tea"
".config/whatsapp-for-linux"
@ -132,6 +134,7 @@
".local/share/Steam"
".local/share/SuperCollider"
".local/share/TelegramDesktop"
".local/share/nvim"
{
directory = ".local/share/containers";
method = "symlink";
@ -180,7 +183,6 @@
ansible
bind.dnsutils
docker-compose
drawterm
file
gimp
gnumake