helm/profiles/nvim/nvim.nix

334 lines
8.5 KiB
Nix
Raw Normal View History

2021-10-04 08:23:05 -07:00
{ pkgs, ... }:
2021-10-10 01:34:18 -07:00
let
customPlugins = {
vim-zettel = pkgs.vimUtils.buildVimPlugin {
name = "vim-zettel";
src = pkgs.fetchFromGitHub {
owner = "michal-h21";
repo = "vim-zettel";
rev = "929d90eec62e6f693c2702d2b6f76a93f2f1689d";
sha256 = "1fzKmknfVlEYwqeXgbKITbb2/PJ023iJyMz6vak3qh4=";
};
};
vimwiki-dev = pkgs.vimUtils.buildVimPlugin {
name = "vimwiki-dev";
src = pkgs.fetchFromGitHub {
owner = "vimwiki";
repo = "vimwiki";
rev = "d035a3428c6343b4f218e51340ddf690ad8c57ee";
sha256 = "000000000000000000000000PJ023iJyMz6vak3qh4=";
};
};
taskwiki-t = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "taskwiki";
version = "2021-09-22";
src = pkgs.fetchFromGitHub {
owner = "tools-life";
repo = "taskwiki";
rev = "c4392c36c01cfffcb06f460d722990b98bc53bdb";
sha256 = "QrxFqu/Y6FykXGqIlK52+nDwmnBhubURl6v2Zc/KwPw=";
};
meta.homepage = "https://github.com/tools-life/taskwiki/";
};
};
my-python-packages = python-packages: with python-packages; [
tasklib
pynvim
six
python-lsp-server
pylsp-mypy
python-lsp-black
pylint
# other python packages you want
];
python-with-my-packages = pkgs.python3.withPackages my-python-packages;
2021-10-10 01:34:18 -07:00
in
{
environment.variables.EDITOR = "nvim";
environment.shellAliases = {
k = "vim -c :VimwikiIndex";
kz = "vim -c :VimwikiIndex -c :ZettelNew";
};
environment.systemPackages = with pkgs // customPlugins; [
nodejs
python-with-my-packages
clojure-lsp
rnix-lsp
terraform-lsp
# Other LSPs
( neovim.override {
vimAlias = true;
withPython3 = true;
extraPython3Packages = pkgs: with pkgs; [ tasklib six ];
configure = {
2021-10-04 08:23:05 -07:00
packages.myPlugins = with pkgs.vimPlugins; {
start = [
vim-nix
fzf-vim
vim-elixir
emmet-vim
nerdtree
ayu-vim
2021-10-04 08:23:05 -07:00
goyo-vim
vim-sneak
csv-vim
rainbow_parentheses-vim
vim-surround
vim-devicons
# kitaab stuff
vimwiki
2021-10-04 08:23:05 -07:00
taskwiki
2021-10-10 01:34:18 -07:00
vim-zettel
telescope-nvim
plenary-nvim
bufferline-nvim
# lsp stuff
ale
nvim-lspconfig
nvim-cmp
2022-02-25 10:20:07 -08:00
cmp-nvim-lsp
nvim-lsp-ts-utils
cmp-conjure
cmp-buffer
cmp-tabnine
lspkind-nvim
# git stuff
vim-fugitive
gitsigns-nvim
fzf-checkout-vim
# Clojure stuff
conjure
vim-sexp
vim-sexp-mappings-for-regular-people
# testing
#vim-processing
#vim-tidal
2021-10-04 08:23:05 -07:00
];
};
customRC = ''
set tabstop=2
set showmatch
set shiftwidth=2
set noexpandtab
set autoindent
set undofile
" set foldmethod=indent " fold based on indent
set number
set nocompatible
set relativenumber
set showtabline=2
set noexpandtab
set autowriteall
2021-10-04 08:23:05 -07:00
syntax on
set list lcs=tab:\|\
filetype plugin on
set termguicolors
let ayucolor="mirage"
colorscheme ayu
2021-10-04 08:23:05 -07:00
" set spell
set spelllang=en_gb
2021-10-04 08:23:05 -07:00
" window
2022-02-25 06:55:19 -08:00
nmap <leader>wh :topleft vnew<CR>
nmap <leader>wl :botright vnew<CR>
2022-02-25 06:55:19 -08:00
nmap <leader>wk :topleft new<CR>
nmap <leader>wj :botright new<CR>
2022-02-08 02:03:49 -08:00
" tabs
nmap <leader>rt :retab!<CR>
2021-10-04 08:23:05 -07:00
let mapleader = "\<Space>"
let maplocalleader = ","
2021-10-04 08:23:05 -07:00
" moving splits with vim movements.
:tnoremap <A-h> <C-\><C-N><C-w>h
:tnoremap <A-j> <C-\><C-N><C-w>j
:tnoremap <A-k> <C-\><C-N><C-w>k
:tnoremap <A-l> <C-\><C-N><C-w>l
:inoremap <A-h> <C-\><C-N><C-w>h
:inoremap <A-j> <C-\><C-N><C-w>j
:inoremap <A-k> <C-\><C-N><C-w>k
:inoremap <A-l> <C-\><C-N><C-w>l
:nnoremap <A-h> <leader>h
:nnoremap <A-j> <leader>j
:nnoremap <A-k> <leader>k
:nnoremap <A-l> <leader>l
:nnoremap <F5> "=strftime("%Y-%m-%d %H:%M:")
:inoremap <F5> <C-R>=strftime("%Y-%m-%d %H:%M:")
" telescope
" Find files using Telescope command-line sugar.
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
2022-02-08 02:03:49 -08:00
" exit normal mode in terminal
:tnoremap <C-n> <C-\><C-n>
2021-10-04 08:23:05 -07:00
" Sexp in Conjure (since it's fennel)
" let g:sexp_filetypes = [ "fennel" ]
2021-10-10 01:34:18 -07:00
let g:rainbow_active = 0
autocmd BufReadPost,BufNewFile c,py,nix RainbowParenthesesToggleAll
2021-10-04 08:23:05 -07:00
2022-02-25 06:55:19 -08:00
" general commands
2021-10-04 08:23:05 -07:00
map <leader>t :NERDTreeToggle<CR>
map <leader>s :w<CR>
map <leader>q :wq<CR>
map <leader>r :RainbowParenthesesToggleAll<CR>
2022-02-25 06:55:19 -08:00
map <leader><BS> :noh<CR>
nnoremap Y y$
" center moving
nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap J mzJ'z
" undo points
inoremap , ,<c-g>u
inoremap . .<c-g>u
inoremap ! !<c-g>u
inoremap ? ?<c-g>u
inoremap ( (<c-g>u
inoremap ) )<c-g>u
inoremap [ [<c-g>u
inoremap ] ]<c-g>u
inoremap { {<c-g>u
inoremap } }<c-g>u
" moving text
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '>-2<CR>gv=gv
inoremap <c-j> <esc>:m .+1<CR>==
inoremap <c-k> <esc>:m .-2<CR>==
nnoremap <leader>j <esc>:m .+1<CR>==
nnoremap <leader>k <esc>:m .-2<CR>==
" Pasting
:map <leader>sy :!xclip -i<CR><CR>
:vmap <leader>sy "*y
:map <leader>sp :r!xclip -o<CR>
2022-02-25 06:55:19 -08:00
" git
nmap <leader>gd :SignifyDiff<CR>
map <leader>ghu :SignifyHunkUndo<CR>
nmap <leader>gl :SignifyList<CR>
nnoremap <leader>ga :G fetch --all
2022-02-25 06:55:19 -08:00
nmap <leader>gs :G<CR>
nmap <leader>gh :diffget //3
nmap <leader>gl :diffget //2
nmap <leader>gc :GCheckout<CR>
2022-02-25 06:55:19 -08:00
" kitaab
map <leader>zs :ZettelSearch<CR>
map <leader>zo :ZettelOpen<CR>
map <leader>zn :ZettelNew<CR>
2021-10-04 08:23:05 -07:00
" NERDTree
" open on directory
autocmd StdinReadPre * let s:std_in=1
2022-02-25 06:55:19 -08:00
" fzf
let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.8 } }
" ALE + clj-kondo
let g:ale_linters = {'clojure': ['clj-kondo'], 'python': ['black', 'pylint']}
2022-02-08 02:03:49 -08:00
2021-10-04 08:23:05 -07:00
" if hidden is not set, TextEdit might fail.
set hidden
" Some servers have issues with backup files, see #649
set nobackup
set nowritebackup
" Better display for messages
set cmdheight=2
" You will have bad experience for diagnostic messages when it's default 4000.
set updatetime=300
" don't give |ins-completion-menu| messages.
set shortmess+=c
" always show signcolumns
set signcolumn=yes
" lsp commands
nnoremap <leader>vd :lua vim.lsp.buf.definition()<CR>
nnoremap <leader>vi :lua vim.lsp.buf.implementation()<CR>
nnoremap <leader>vsh :lua vim.lsp.buf.signature_help()<CR>
nnoremap <leader>vrr :lua vim.lsp.buf.references()<CR>
nnoremap <leader>vrn :lua vim.lsp.buf.rename()<CR>
nnoremap <leader>vh :lua vim.lsp.buf.hover()<CR>
nnoremap <leader>vca :lua vim.lsp.buf.code_action()<CR>
nnoremap <leader>vsd :lua vim.lsp.diagnostic.show_line_diagnostics(); vim.lsp.util.show_line_diagnostics()<CR>
nnoremap <leader>vn :lua vim.lsp.diagnostic.goto_next()<CR>
nnoremap <leader>vll :call LspLocationList()<CR>
"bufferline
" These commands will navigate through buffers in order regardless of which mode you are using
nnoremap <silent>[b :BufferLineCycleNext<CR>
nnoremap <silent>b] :BufferLineCyclePrev<CR>
" lua config
lua <<EOF
-- Setup nvim-cmp.
local cmp = require'cmp'
cmp.setup({
mapping = {
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
['<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 = 'buffer' },
})
})
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
sources = {
{ name = 'buffer' },
{ name = "nvim_lsp"},
{ name = "path" },
{ name = 'conjure'},
{ name = 'cmp_tabnine'},
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- Setup lspconfig.
-- local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
-- require'lspconfig'nvim_lsp.setup {}
-- require'lspconfig'clojure_lsp.setup {}
-- require'lspconfig'rnix.setup {}
-- require'lspconfig'pylsp.setup {}
-- require'lspconfig'terraform_lsp.setup {}
-- Bufferline
require('bufferline').setup {}
EOF
2021-10-04 08:23:05 -07:00
'';
};
}
)];
}