rice/programs/nvim.nix

556 lines
18 KiB
Nix
Raw Normal View History

2022-08-14 00:01:29 +00:00
{
lib,
pkgs,
...
2022-08-16 19:14:35 +00:00
} @ inputs: {
2022-07-22 20:42:05 +00:00
home-manager.users.buffet = {
home.sessionVariables = {
EDITOR = "nvim";
};
home.packages = with pkgs; [
clang-tools
nil
rust-analyzer
2023-06-19 08:53:33 +00:00
sumneko-lua-language-server
];
2022-08-16 21:07:40 +00:00
programs.neovim = let
leader = ",";
in {
2022-07-22 20:42:05 +00:00
enable = true;
2022-08-16 19:14:35 +00:00
plugins = let
2022-12-02 16:55:53 +00:00
buildPlugin = pname:
pkgs.vimUtils.buildVimPluginFrom2Nix {
inherit pname;
version = "unknown";
src = inputs."${pname}";
2022-08-16 19:14:35 +00:00
};
buildPlugins = names: lib.attrsets.genAttrs names buildPlugin;
2022-08-25 16:57:02 +00:00
plugins = buildPlugins [
2022-08-25 17:34:17 +00:00
"cmp-conventionalcommits"
2022-08-25 16:57:02 +00:00
"cmp-git"
2023-01-17 08:50:03 +00:00
"gh-nvim"
2023-03-10 21:11:36 +00:00
"nvim-cmp-vlime"
"rust-tools-nvim"
2023-06-12 09:01:49 +00:00
"vim-hy"
2023-02-27 14:56:01 +00:00
"vlime"
2022-08-25 16:57:02 +00:00
];
2022-08-16 19:14:35 +00:00
in
with pkgs.vimPlugins;
with plugins; [
2022-08-25 16:57:02 +00:00
{plugin = cmp-buffer;}
{plugin = cmp-calc;}
2022-08-25 17:34:17 +00:00
{plugin = cmp-conventionalcommits;}
2022-08-25 16:57:02 +00:00
{plugin = cmp-latex-symbols;}
{plugin = cmp-nvim-lsp;}
{plugin = cmp-path;}
{plugin = cmp-treesitter;}
{plugin = cmp-vsnip;}
2022-08-16 19:14:35 +00:00
{plugin = editorconfig-nvim;}
2023-06-20 09:31:16 +00:00
{plugin = fennel-vim;}
2022-08-25 16:57:02 +00:00
{plugin = friendly-snippets;}
2022-08-16 19:14:35 +00:00
{plugin = fugitive;}
{plugin = lualine-lsp-progress;}
2023-03-10 21:11:36 +00:00
{plugin = nvim-cmp-vlime;}
2023-03-10 21:11:59 +00:00
{plugin = parinfer-rust;}
2023-07-03 09:53:37 +00:00
{plugin = pest-vim;}
{plugin = playground;}
2022-08-16 19:14:35 +00:00
{plugin = rust-vim;}
{plugin = tabular;}
{plugin = vim-nix;}
2023-06-12 09:01:49 +00:00
{plugin = vim-hy;}
2023-06-19 08:53:33 +00:00
{plugin = vim-repeat;}
2023-02-27 14:56:01 +00:00
{plugin = vlime;}
2022-07-22 20:42:05 +00:00
2022-08-25 16:57:02 +00:00
{
plugin = cmp-git;
2023-04-03 16:40:02 +00:00
config = "lua require 'cmp_git'.setup {}";
}
2022-08-25 16:01:06 +00:00
{
plugin = crates-nvim;
config = ''
2023-04-03 16:40:02 +00:00
lua require 'crates'.setup {}
2022-08-25 16:01:06 +00:00
nnoremap <silent> ${leader}ct :lua require('crates').toggle()<cr>
nnoremap <silent> ${leader}cr :lua require('crates').reload()<cr>
nnoremap <silent> ${leader}cv :lua require('crates').show_versions_popup()<cr>
nnoremap <silent> ${leader}cf :lua require('crates').show_features_popup()<cr>
nnoremap <silent> ${leader}cd :lua require('crates').show_dependencies_popup()<cr>
nnoremap <silent> ${leader}cu :lua require('crates').update_crate()<cr>
vnoremap <silent> ${leader}cu :lua require('crates').update_crates()<cr>
nnoremap <silent> ${leader}ca :lua require('crates').update_all_crates()<cr>
nnoremap <silent> ${leader}cU :lua require('crates').upgrade_crate()<cr>
vnoremap <silent> ${leader}cU :lua require('crates').upgrade_crates()<cr>
nnoremap <silent> ${leader}cA :lua require('crates').upgrade_all_crates()<cr>
nnoremap <silent> ${leader}cH :lua require('crates').open_homepage()<cr>
nnoremap <silent> ${leader}cR :lua require('crates').open_repository()<cr>
nnoremap <silent> ${leader}cD :lua require('crates').open_documentation()<cr>
nnoremap <silent> ${leader}cC :lua require('crates').open_crates_io()<cr>
'';
}
2023-01-17 08:50:03 +00:00
{
plugin = gh-nvim;
config = ''
lua <<EOF
require 'litee.lib'.setup {}
require 'litee.gh'.setup {}
EOF
nnoremap <silent> ${leader}qcc :GHCloseCommit<cr>
nnoremap <silent> ${leader}qce :GHExpandCommit<cr>
nnoremap <silent> ${leader}qct :GHOpenToCommit<cr>
nnoremap <silent> ${leader}qcp :GHPopOutCommit<cr>
nnoremap <silent> ${leader}qcz :GHCollapseCommit<cr>
nnoremap <silent> ${leader}qip :GHPreviewIssue<cr>
nnoremap <silent> ${leader}qrb :GHStartReview<cr>
nnoremap <silent> ${leader}qrc :GHCloseReview<cr>
nnoremap <silent> ${leader}qrd :GHDeleteReview<cr>
nnoremap <silent> ${leader}qre :GHExpandReview<cr>
nnoremap <silent> ${leader}qrs :GHSubmitReview<cr>
nnoremap <silent> ${leader}qrz :GHCollapseReview<cr>
nnoremap <silent> ${leader}qpc :GHClosePR<cr>
nnoremap <silent> ${leader}qpd :GHPRDetails<cr>
nnoremap <silent> ${leader}qpe :GHExpandPR<cr>
nnoremap <silent> ${leader}qpo :GHOpenPR<cr>
nnoremap <silent> ${leader}qpp :GHPopOutPR<cr>
nnoremap <silent> ${leader}qpr :GHRefreshPR<cr>
nnoremap <silent> ${leader}qpt :GHOpenToPR<cr>
nnoremap <silent> ${leader}qpz :GHCollapsePR<cr>
nnoremap <silent> ${leader}qtc :GHCreateThread<cr>
nnoremap <silent> ${leader}qtn :GHNextThread<cr>
nnoremap <silent> ${leader}qt :GHToggleThread<cr>
'';
}
{
plugin = gitsigns-nvim;
config = ''
lua <<EOF
require 'gitsigns'.setup {
signs = {
add = { text = '' },
change = { text = '' },
},
}
EOF
'';
}
{
plugin = litee-nvim;
config = ''
lua require 'litee.lib'.setup {}
nnoremap <silent> ${leader}lt :LTPanel<cr>
'';
}
{
plugin = litee-calltree-nvim;
config = ''
lua require 'litee.calltree'.setup {}
nnoremap <silent> ${leader}lci :lua vim.lsp.buf.incoming_calls()<cr>
nnoremap <silent> ${leader}lco :lua vim.lsp.buf.outgoing_calls()<cr>
'';
}
{
plugin = litee-symboltree-nvim;
config = ''
lua require 'litee.symboltree'.setup {}
nnoremap <silent> ${leader}ls :lua vim.lsp.buf.document_symbol()<cr>
'';
}
2022-08-16 19:14:35 +00:00
{
plugin = lualine-nvim;
2022-08-17 11:24:05 +00:00
config = ''
lua <<EOF
require 'lualine'.setup {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = {left = ''', right = '''},
section_separators = {left = ''', right = '''},
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
lualine_a = {'mode'},
lualine_b = {'diff', 'diagnostics'},
lualine_c = {
'filename',
{
'lsp_progress',
display_components = {'lsp_client_name', 'spinner'},
spinner_symbols = {'', '', '', '', '', ''},
timer = {spinner = '75'}
}
},
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}
EOF
2022-08-17 11:24:05 +00:00
'';
2022-08-16 19:14:35 +00:00
}
2022-07-22 20:42:05 +00:00
2022-08-16 19:14:35 +00:00
{
plugin = kanagawa-nvim;
2022-08-16 19:14:35 +00:00
config = ''
2023-06-12 10:09:54 +00:00
colorscheme kanagawa
2023-01-11 15:56:27 +00:00
lua <<EOF
local colors = require 'kanagawa.colors'.setup();
require 'kanagawa'.setup {
overrides = {
EndOfBuffer = { fg = colors.waveBlue2 },
},
}
EOF
2022-08-16 19:14:35 +00:00
'';
}
2022-07-22 20:42:05 +00:00
2023-01-17 08:53:56 +00:00
{
plugin = lspsaga-nvim;
config = ''
lua require 'lspsaga'.init_lsp_saga()
nnoremap <silent> ${leader}a :Lspsaga code_action<cr>
nnoremap <silent> ${leader}r :Lspsaga rename<cr>
nnoremap <silent> gd :lua vim.lsp.buf.definition()<cr>
nnoremap <silent> gD :lua vim.lsp.buf.declaration()<cr>
'';
}
2022-08-25 16:57:02 +00:00
{
plugin = nvim-cmp;
config = ''
set completeopt=menu,menuone,noselect
lua <<EOF
local cmp = require 'cmp'
cmp.setup {
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = {
2023-04-03 16:40:02 +00:00
['<tab>'] = cmp.mapping.confirm({ select = true }),
2022-08-25 16:57:02 +00:00
['<c-p>'] = cmp.mapping.select_prev_item(select_opts),
['<c-n>'] = cmp.mapping.select_next_item(select_opts),
['<c-d>'] = cmp.mapping.scroll_docs(4),
['<c-u>'] = cmp.mapping.scroll_docs(-4),
['<c-e>'] = cmp.mapping.abort(),
},
sources = cmp.config.sources {
{ name = 'buffer' },
{ name = 'calc' },
2022-08-25 17:34:17 +00:00
{ name = 'conventionalcommits' },
2022-08-25 16:57:02 +00:00
{ name = 'crates' },
{ name = 'git' },
{ name = 'latex_symbols' },
{ name = 'nvim_lsp' },
{ name = 'path' },
{ name = 'treesitter' },
2023-03-10 21:11:36 +00:00
{ name = 'vlime' },
2022-08-25 16:57:02 +00:00
{ name = 'vsnip' },
},
}
EOF
'';
}
{
plugin = nvim-dap;
config = ''
nnoremap <silent> <f5> <cmd>lua require 'dap'.continue()<cr>
nnoremap <silent> <f10> <cmd>lua require 'dap'.step_over()<cr>
nnoremap <silent> <f11> <cmd>lua require 'dap'.step_into()<cr>
nnoremap <silent> <f12> <cmd>lua require 'dap'.step_out()<cr>
nnoremap <silent> ${leader}db <cmd>lua require'dap'.toggle_breakpoint()<cr>
nnoremap <silent> ${leader}dB <cmd>lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<cr>
nnoremap <silent> ${leader}dr <cmd>lua require'dap'.repl.open()<cr>
nnoremap <silent> ${leader}dl <cmd>lua require'dap'.run_last()<cr>
lua <<EOF
local dap = require 'dap'
dap.adapters.lldb = {
type = 'executable',
command = '${pkgs.lldb}/bin/lldb-vscode',
name = 'lldb',
}
local lldb = {
name = 'Launch lldb',
type = 'lldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = "''${workspaceFolder}",
stopOnEntry = false,
runInTerminal = true,
args = {},
}
dap.configurations.rust = { lldb }
EOF
'';
}
{
plugin = nvim-dap-ui;
config = ''
lua require 'dapui'.setup()
'';
}
{
plugin = nvim-dap-virtual-text;
config = ''
lua <<EOF
require 'nvim-dap-virtual-text'.setup {
commented = true,
}
EOF
'';
}
2023-01-17 08:53:56 +00:00
{
plugin = nvim-hlslens;
config = ''
lua require 'hlslens'.setup {}
'';
}
{
plugin = nvim-lspconfig;
config = let
configure = srv: ''
lspconfig.${srv}.setup {
capabilities = caps,
}
'';
servers = [
"clangd"
"gopls"
2023-06-19 08:53:33 +00:00
"lua_ls"
"nil_ls"
2023-01-17 08:53:56 +00:00
"rust_analyzer"
];
serverConfigs = lib.strings.concatStringsSep "\n" (builtins.map configure servers);
in ''
lua <<EOF
local lspconfig = require 'lspconfig'
local caps = require 'cmp_nvim_lsp'.default_capabilities(
vim.lsp.protocol.make_client_capabilities()
)
${serverConfigs}
EOF
'';
}
2022-08-16 19:14:35 +00:00
{
plugin = nvim-treesitter.withPlugins (plugins:
with plugins; [
tree-sitter-bash
tree-sitter-bibtex
tree-sitter-c
tree-sitter-c-sharp
tree-sitter-clojure
2022-08-16 19:14:35 +00:00
tree-sitter-cmake
tree-sitter-comment
2023-02-27 14:56:01 +00:00
tree-sitter-commonlisp
2022-08-16 19:14:35 +00:00
tree-sitter-cpp
tree-sitter-css
tree-sitter-devicetree
tree-sitter-dockerfile
tree-sitter-dot
2022-08-16 19:14:35 +00:00
tree-sitter-fennel
tree-sitter-glsl
2022-08-16 19:14:35 +00:00
tree-sitter-go
tree-sitter-java
2022-08-16 19:14:35 +00:00
tree-sitter-javascript
tree-sitter-json
tree-sitter-latex
tree-sitter-llvm
2022-08-16 19:14:35 +00:00
tree-sitter-lua
tree-sitter-make
tree-sitter-markdown
tree-sitter-markdown-inline
2022-08-16 19:14:35 +00:00
tree-sitter-nix
tree-sitter-perl
tree-sitter-python
tree-sitter-regex
tree-sitter-rst
2022-08-16 19:14:35 +00:00
tree-sitter-rust
tree-sitter-sql
2023-02-27 14:56:01 +00:00
tree-sitter-scheme
tree-sitter-svelte
2022-08-16 19:14:35 +00:00
tree-sitter-toml
tree-sitter-typescript
tree-sitter-vim
tree-sitter-yaml
tree-sitter-zig
2022-08-16 19:14:35 +00:00
]);
2022-08-17 12:19:53 +00:00
config = ''
lua <<EOF
require 'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
}
EOF
2022-08-16 20:10:01 +00:00
'';
2022-08-16 19:14:35 +00:00
}
2022-08-16 20:11:38 +00:00
2023-01-17 08:53:56 +00:00
{
plugin = rust-tools-nvim;
config = ''
lua require 'rust-tools'.setup {}
'';
}
{
plugin = telescope-nvim;
config = ''
nnoremap <silent> ${leader}f :Telescope find_files<cr>
nnoremap <silent> ${leader}F :Telescope find_files hidden=true no_ignore=true<cr>
nnoremap <silent> ${leader}g :Telescope live_grep<cr>
nnoremap <silent> ${leader}b :Telescope buffers<cr>
nnoremap <silent> ${leader}: :Telescope commands<cr>
'';
}
{
plugin = trouble-nvim;
config = ''
nnoremap <silent> ${leader}t :TroubleToggle<cr>
'';
}
2022-08-25 16:57:02 +00:00
{
plugin = vim-vsnip;
config = ''
imap <expr> <c-k> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'
smap <expr> <c-k> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'
imap <expr> <c-j> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
smap <expr> <c-j> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
'';
}
2022-08-16 20:11:38 +00:00
{
plugin = vimwiki;
# TODO: vimwiki config
}
2022-08-16 19:14:35 +00:00
];
2022-08-16 21:07:40 +00:00
2022-08-17 11:24:05 +00:00
extraConfig = let
theme = import ../theme.nix;
in ''
" keybinds
2022-08-16 21:07:40 +00:00
let mapleader = "${leader}"
let g:mapleader = "${leader}"
2022-08-17 10:48:32 +00:00
inoremap kj <esc>
vnoremap < <gv
vnoremap > >gv
nnoremap <c-h> <c-w>h
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-l> <c-w>l
nnoremap <leader>s :w<cr>
2022-08-17 11:24:05 +00:00
" misc
set termguicolors
set mouse=a
set undofile
set hidden
set encoding=utf-8
set hlsearch
set incsearch
set ignorecase
set smartcase
set lazyredraw
set splitbelow
set splitright
set matchtime=2
set showmatch
2022-08-21 14:55:51 +00:00
set wrap
set breakindent
2022-08-17 11:24:05 +00:00
set nowritebackup
set updatetime=250
set colorcolumn=+1
set cursorline
2023-01-11 15:56:16 +00:00
set signcolumn=yes
2022-08-17 11:24:05 +00:00
set shiftwidth=4
set tabstop=4
set expandtab
set shiftround
set autoindent
set smartindent
highlight! ExtraWhitespace guibg=${theme.normal.red}
match ExtraWhitespace /\s\+$/
autocmd FileType lisp setlocal shiftwidth=2 tabstop=2
lua <<EOF
vim.diagnostic.config {
severity_sort = true,
}
EOF
2022-08-16 21:07:40 +00:00
'';
2022-07-22 20:42:05 +00:00
};
};
}