helm/home/profiles/nvim/default.nix
2025-09-12 00:29:37 -07:00

1103 lines
42 KiB
Nix
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ pkgs, ... }:
let
customPlugins = {
vim-zettel = pkgs.vimUtils.buildVimPlugin {
name = "vim-zettel";
src = pkgs.fetchFromGitHub {
owner = "michal-h21";
repo = "vim-zettel";
rev = "929d90eec62e6f693c2702d2b6f76a93f2f1689d";
sha256 = "1fzKmknfVlEYwqeXgbKITbb2/PJ023iJyMz6vak3qh4=";
};
};
my-lspsaga = pkgs.vimUtils.buildVimPlugin {
name = "lspsaga.nvim";
src = pkgs.fetchFromGitHub {
owner = "glepnir";
repo = "lspsaga.nvim";
rev = "b7b4777369b441341b2dcd45c738ea4167c11c9e";
sha256 = "sciX/fMxzY1YOxXxjj1+ymrdMi451avcFFu+14R+/pk=";
};
};
nvim-luapad = pkgs.vimUtils.buildVimPlugin {
name = "nvim-luapad";
src = pkgs.fetchFromGitHub {
owner = "rafcamlet";
repo = "nvim-luapad";
rev = "9815e2659ce8e2ef4b55e401531cf09b6423e0ea";
sha256 = "gMaS5YFi3+gmUIfkCMEt9vhm8XSgv54Cquv5+WCWeTo=";
};
};
leap = pkgs.vimUtils.buildVimPlugin {
name = "leap";
src = pkgs.fetchFromGitHub {
owner = "ggandor";
repo = "leap.nvim";
rev = "1bb1fec369b1e9ae96e6ff1b829ea9272c51f844";
sha256 = "dH0v1D5q5OlMLA/omTDMb/taKyIgQ5VfVMYXJ609k/k=";
};
};
nvim-navic = pkgs.vimUtils.buildVimPlugin {
name = "nvim-navic";
src = pkgs.fetchFromGitHub {
owner = "SmiteshP";
repo = "nvim-navic";
rev = "096b23e73c84a653fd317c0c10261875fa573a6d";
sha256 = "vX7ZVJxgatIicmijehtaRvyHxk1i4gFfXrbPM/+VoFc=";
};
};
my-which-key-nvim = pkgs.vimUtils.buildVimPlugin {
pname = "which-key.nvim";
version = "2022-05-04";
src = pkgs.fetchFromGitHub {
owner = "folke";
repo = "which-key.nvim";
rev = "bd4411a2ed4dd8bb69c125e339d837028a6eea71";
sha256 = "0vf685xgdb967wmvffk1pfrvbhg1jkvzp1kb7r0vs90mg8gpv1aj";
};
meta.homepage = "https://github.com/folke/which-key.nvim/";
};
yuck-vim = pkgs.vimUtils.buildVimPlugin {
pname = "yuck.vim";
version = "2021-08-09";
src = pkgs.fetchFromGitHub {
owner = "elkowar";
repo = "yuck.vim";
rev = "6dc3da77c53820c32648cf67cbdbdfb6994f4e08";
sha256 = "lp7qJWkvelVfoLCyI0aAiajTC+0W1BzDhmtta7tnICE=";
};
};
nvim-parinfer = pkgs.vimUtils.buildVimPlugin {
pname = "nvim-parinfer";
version = "v1.2.0";
src = pkgs.fetchFromGitHub {
owner = "gpanders";
repo = "nvim-parinfer";
rev = "82bce5798993f4fe5ced20e74003b492490b4fe8";
sha256 = "Dlzfp3CZTzq8zQeHByWf3ER6/Em+KNGYNI4Z17ui8Lc=";
};
};
my-marks = pkgs.vimUtils.buildVimPlugin {
pname = "marks";
version = "2022-08-31";
src = pkgs.fetchFromGitHub {
owner = "chentoast";
repo = "marks.nvim";
rev = "b27cbb78e9082229590b396d3ae4fe07f1aeafe0";
sha256 = "XdbgIWuAHNdTfyKDrKmQVq5oSbBoi56DpwtgOqhScAk=";
};
};
my-fterm = pkgs.vimUtils.buildVimPlugin {
pname = "fterm";
version = "2022-07-22";
src = pkgs.fetchFromGitHub {
owner = "numToStr";
repo = "FTerm.nvim";
rev = "efd10656724a269e21ba68d65e2b058a4e606424";
sha256 = "rR6KDwj58aYfyaSsoUy75536SdBhk394yspCUl/hzfE=";
};
};
my-nvim-peekup = pkgs.vimUtils.buildVimPlugin {
pname = "nvim-peekup";
version = "0.1.0";
src = pkgs.fetchFromGitHub {
owner = "gennaro-tedesco";
repo = "nvim-peekup";
rev = "73a67c1ee3b5a7ea7b42d85399bf093f428c8ee3";
sha256 = "czKjJgCpvRSdtR7rNGlJrluDgPIdx94KUyx33op5gdY=";
};
};
};
my-python-packages = python-packages: with python-packages; [
tasklib
pynvim
six
# other python packages you want
];
python-with-my-packages = pkgs.python3.withPackages my-python-packages;
in
{
home.sessionVariables.EDITOR = "nvim";
home.shellAliases = {
k = "cd ~/kitaab/vimwiki; vim -c :VimwikiIndex; cd $OLDPWD";
# kitaab zettel
kz = "cd ~/kitaab/vimwiki; vim -c :VimwikiIndex -c :ZettelNew; cd $OLDPWD";
# kitaab recents
kr = "cd /home/anish/kitaab/vimwiki; eza --sort=modified --reverse | fzf --preview 'bat --style=numbers --color=always --terminal-width -1 ./{}';cd $OLDPWD";
# kitaab get by tagged
kt = "cd /home/anish/kitaab/vimwiki; eza *_index.wiki | fzf --preview 'bat --style=numbers --color=always --terminal-width -1 ./{}';cd $OLDPWD";
# List files that have no links in them
ku = "cd /home/anish/kitaab/;vim ./vimwiki/$(python3 poonam/main.py report --titles=false | tail -n +4 | fzf --preview 'bat --style=numbers --color=always --terminal-width -1 ./vimwiki/{}');cd $OLDPWD";
};
# Add %update to the highlight clause for vimwiki files
home.file.".config/nvim/after/syntax/vimwiki.vim".text = ''
" match with %update
syntax match VimwikiPlaceholder /^\s*%update\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
" match with %link
syntax match VimwikiPlaceholder /^\s*%link\ze\%(\s.*\)\?$/ nextgroup=VimwikiPlaceholderParam skipwhite
'';
#environment.systemPackages = with customPlugins; [ tidal ];
programs.neovim = {
enable = true;
extraConfig = ''
" so our custom files still get included
set runtimepath+=/home/anish/.config/nvim/
set tabstop=2
set showmatch
set shiftwidth=2
set noexpandtab
set autoindent
set undofile
set signcolumn=auto:4
set title
" set foldmethod=indent " fold based on indent
set number
set nocompatible
set relativenumber
set showtabline=2
set noexpandtab
set autowriteall
set list lcs=tab:\|\
filetype plugin on
" include - in word to move across easier in lisp / clojure
set iskeyword+=-
set termguicolors
colorscheme ayu-mirage
" set spell
set spelllang=en_gb
set ignorecase
set smartcase
set incsearch
" 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=0
" 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
" highlight row
set cursorline
set autoread
let mapleader = "\<Space>"
let maplocalleader = ","
" window
nmap <leader>wh :topleft vnew<CR>
nmap <leader>wl :botright vnew<CR>
nmap <leader>wk :topleft new<CR>
nmap <leader>wj :botright new<CR>
" tabs
nmap <leader>rt :retab!<CR>
vmap <leader>rt :retab!<CR>
" Alt+hjkl navigation now handled by Navigator.nvim plugin
:nnoremap <F5> "=strftime("%Y-%m-%d %H:%M")<CR>
:inoremap <F5> <C-R>=strftime("%Y-%m-%d %H:%M")<CR>
:inoremap <F4> <C-R>=strftime("%H:%M")<CR>
" tidal nvim terminal
let g:tidal_target = "terminal"
" latex
" let g:tex_flavor='latex'
" let g:vimtex_view_method='zathura'
" let g:vimtex_quickfix_mode=0
" set conceallevel=1
" let g:tex_conceal='abdmg'
" 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>
nnoremap <leader>ft <cmd>Telescope tags<cr>
" exit normal mode in terminal
:tnoremap <C-n> <C-\><C-n>
" Sexp in Conjure (since it's fennel)
let g:sexp_filetypes = "clojure,scheme,lisp,janet,fennel,yuck"
let g:conjure#filetype#fennel = "conjure.client.fennel.stdio"
" we only use fennel with love; no we don't...
let g:conjure#client#fennel#stdio#command = "fennel"
" let g:conjure#extract#tree_sitter#enabled = true
map <localleader>lt :ConjureLogToggle<CR>
let g:rainbow_active = 0
autocmd BufReadPost,BufNewFile c,clj,cljs RainbowParenthesesToggleAll
" general commands
map <leader>e :Neotree toggle<CR>
map <leader>s :w<CR>
map <leader>q :q<CR>
map <leader>r :RainbowParenthesesToggleAll<CR>
nnoremap <Esc> :noh<CR>
map Q <Nop>
nnoremap Y y$
nnoremap <leader>n :vnew<CR>
" 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>
" buffer navigation (using built-in commands)
nnoremap <silent> gT :bprevious<CR>
nnoremap <silent> gt :bnext<CR>
nnoremap <silent> gj :buffers<CR>
nnoremap <silent> gq :bdelete<CR>
" git
nnoremap <leader>ga :G fetch --all
nmap <leader>gs :G<CR>
nmap <leader>gl :diffget //3<CR>
nmap <leader>gh :diffget //2<CR>
nmap <leader>gb :GBranches<CR>
nnoremap <leader>gp :Git! push<CR>
nnoremap <leader>gd :Gdiff<CR>
nnoremap <leader>gc :G commit -v -q %:p<CR>
" kitaab
"map <leader>cz :VimwikiIndex<CR>:ZettelNew
"map <leader>zs :ZettelSearch<CR>
map <leader>zn :ZettelNew<CR>
"map <leader>zo :ZettelOpen<CR>
"map <leader>zf :Telescope oldfiles only_cwd=true<CR>
"map <leader>wt :VimwikiMakeTomorrowDiaryNote
"map <leader>wd :VimwikiMakeYesterdayDiaryNote
"map <leader>zm :ZenMode<CR>:setlocal nospell<CR>
let g:vimwiki_list = [{ 'path': '~/kitaab/vimwiki', 'auto_tags': 1, 'auto_diary_index': 1, 'auto_generate_links': 1 }]
let g:sync_taskwarrior = 0
let g:zettel_format = "%y%m%d-%H%M"
let g:vimwiki_list = [{'path': '~/kitaab/vimwiki', 'nested_syntaxes': {'python': 'python', 'c++': 'cpp', 'nix': 'nix', 'bash': 'sh'}}]
let g:mapleader="\<Space>"
" fzf
" not sure we even use this
let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.8 } }
" lsp commands
nnoremap <leader>vgd :lua vim.lsp.buf.definition()<CR>
nnoremap <leader>vi :lua require('telescope.builtin').lsp_implementation()<CR>
nnoremap <leader>vsh :lua vim.lsp.buf.signature_help()<CR>
nnoremap <leader>vrr :lua require('telescope.builtin').lsp_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.util.show_line_diagnostics()<CR>
" nnoremap <leader>vn :lua vim.lsp.diagnostic.goto_next()<CR>
" nnoremap <leader>va :lua require('telescope.builtin').lsp_code_actions(require('telescope.themes').get_cursor())<cr>
" lspsaga stuff doesn't work
nnoremap <leader>vd :Lspsaga peek_definition<CR>
nnoremap <leader>vrn :Lspsaga rename<CR><CR>
nnoremap <leader>vh :Lspsaga hover_doc<CR>
nnoremap <leader>vca :Lspsaga code_action<CR>
nnoremap <leader>vsd :Lspsaga show_line_diagnostics<CR>
nnoremap <leader>vs :Dasht<Space>
nnoremap <leader>vn :Lspsaga diagnostic_jump_prev<CR>
nnoremap <leader>co :Outline<CR>
" Trouble keybindings
nnoremap <leader>xx :Trouble diagnostics<CR>
nnoremap <leader>xw :Trouble workspace_diagnostics<CR>
nnoremap <leader>xd :Trouble document_diagnostics<CR>
nnoremap <leader>xl :Trouble loclist<CR>
nnoremap <leader>xq :Trouble quickfix<CR>
nnoremap <leader>xr :Trouble lsp_references<CR>
" Yank to system clipboard (y operations only, not d)
nnoremap y "+y
vnoremap y "+y
nnoremap Y "+Y
" Note-taking keybindings
nnoremap <leader>zz :ZkNew { title = vim.fn.input('Title: ') }<CR>
" dashboard
let g:dashboard_custom_header = [
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\]
let g:dashboard_default_executive = 'telescope'
nmap <Leader>ss :<C-u>SessionSave<CR>
nmap <Leader>sl :<C-u>SessionLoad<CR>
" nnoremap <silent> <Leader>fh :DashboardFindHistory<CR>
" nnoremap <silent> <Leader>fm :DashboardJumpMark<CR>
" nnoremap <silent> <Leader>cn :DashboardNewFile<CR>
autocmd FileType dashboard set showtabline=0 | autocmd WinLeave <buffer> set showtabline=2
let g:dashboard_custom_footer = ["Run wild"]
let g:dashboard_custom_section={
\ 'create_zettel': {
\ 'description': [' Create Zettel SPC c z'],
\ 'command': ':VimwikiIndex' },
\ 'load_session': {
\ 'description': [' Load Session SPC s l'],
\ 'command': 'SessionLoad' }
\ }
let g:scnvim_snippet_format = "luasnip"
" lua config
lua <<EOF
local signs = { Error = " ", Warn = " ", Hint = "💡", Info = " " }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
vim.g.diagnostics_active = true
function _G.toggle_diagnostics()
if vim.g.diagnostics_active then
vim.g.diagnostics_active = false
vim.lsp.diagnostic.clear(0)
vim.lsp.handlers["textDocument/publishDiagnostics"] = function() end
else
vim.g.diagnostics_active = true
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = true,
signs = true,
underline = true,
update_in_insert = false,
}
)
end
end
vim.diagnostic.config({
signs = true,
update_in_insert = false,
underline = false,
severity_sort = true,
float = {
focusable = false,
style = 'minimal',
border = 'rounded',
source = 'always',
},
})
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(
vim.lsp.handlers.hover,
{
border = 'rounded',
}
)
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(
vim.lsp.handlers.signature_help,
{
border = 'rounded',
}
)
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
opts = opts or {}
opts.border = opts.border or 'rounded'
return orig_util_open_floating_preview(contents, syntax, opts, ...)
end
vim.api.nvim_set_keymap('n', '<leader>vt', ':call v:lua.toggle_diagnostics()<CR>', {noremap = true, silent = true})
-- autopairs
require('nvim-autopairs').setup{}
-- marks
require('marks').setup{}
-- Setup nvim-cmp.
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local luasnip = require("luasnip")
local lspkind = require("lspkind")
local cmp = require('cmp')
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local t = function(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
local check_back_space = function()
local col = vim.fn.col(".") - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") ~= nil
end
cmp.setup {
formatting = {
format = lspkind.cmp_format({
mode = 'symbol_text',
maxwidth = 50,
})
},
mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, {"i", "s"}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
},
snippet = {
expand = function(args)
require'luasnip'.lsp_expand(args.body)
end
},
sources = {
{name = 'buffer'}, {name = 'nvim_lsp'},
{name = "look"}, {name = "path"},
{name = "calc"}, {name = "spell"},
{name = 'cmp-conjure'}, {name = "luasnip"},
{name = 'tags'}
},
completion = {completeopt = 'menu,menuone,noinsert'}
}
cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = ' ' } }))
require("luasnip.loaders.from_vscode").lazy_load()
-- lsp-format removed, using conform.nvim instead
require("nvim-navic").setup {
icons = {
Constant = "π ",
Function = "ƒ "
}
}
-- Setup neo-tree
require("neo-tree").setup {}
-- Setup outline
require("outline").setup {}
-- Setup trouble
require("trouble").setup {}
-- Setup noice for floating command palette and notifications
require("noice").setup({
cmdline = {
enabled = true,
view = "cmdline_popup",
},
messages = {
enabled = true,
},
popupmenu = {
enabled = true,
},
notify = {
enabled = true,
view = "notify",
},
lsp = {
progress = {
enabled = true,
format = "lsp_progress",
format_done = "lsp_progress_done",
throttle = 1000 / 30, -- frequency to update lsp progress message
view = "mini",
},
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true,
},
},
presets = {
command_palette = true,
long_message_to_split = true,
inc_rename = false,
lsp_doc_border = false,
},
views = {
cmdline_popup = {
border = {
style = "rounded",
padding = { 0, 1 },
},
filter_options = {},
win_options = {
winhighlight = "NormalFloat:NormalFloat,FloatBorder:FloatBorder",
},
},
},
})
-- Setup barbar (tabline with icons)
require'barbar'.setup {
icons = {
filetype = {
enabled = true,
},
},
}
local navic = require("nvim-navic")
-- Setup conform.nvim for formatting
require("conform").setup({
formatters_by_ft = {
javascript = { "prettier", "lsp" },
typescript = { "prettier", "lsp" },
javascriptreact = { "prettier", "lsp" },
typescriptreact = { "prettier", "lsp" },
json = { "prettier", "lsp" },
html = { "prettier", "lsp" },
css = { "prettier", "lsp" },
yaml = { "prettier", "lsp" },
rust = { "lsp" },
go = { "lsp" },
lua = { "lsp" },
nix = { "nixfmt-rfc-style" },
clojure = { "lsp" },
fennel = { "lsp" },
terraform = { "lsp" },
bash = { "shfmt" },
sh = { "shfmt" },
},
format_on_save = {
timeout_ms = 500,
lsp_fallback = true,
},
})
-- lspsaga, code_action lightbulb is annoying
local saga = require('lspsaga')
saga.init_lsp_saga({
border_style = "rounded",
code_action_icon = "",
code_action_num_shortcut = true,
code_action_lightbulb = {
enable = false,
enable_in_insert = false,
cache_code_action = true,
sign = true,
update_time = 150,
sign_priority = 20,
virtual_text = false,
},
code_action_keys = {
quit = 'q',
exec = '<CR>',
},
-- show outline
show_outline = {
win_position = 'right',
--set special filetype win that outline window split.like NvimTree neotree
-- defx, db_ui
auto_enter = true,
auto_preview = true,
virt_text = '',
jump_key = 'o',
-- auto refresh when change buffer
auto_refresh = true,
},
})
capabilities = require('cmp_nvim_lsp').default_capabilities()
-- fennel-ls is bleeding edge
local lspconfig = require('lspconfig')
require("lspconfig.configs")["fennel-ls"] = {
default_config = {
cmd = {"fennel-ls"},
filetypes = {"fennel"},
root_dir = function(dir) return lspconfig.util.find_git_ancestor(dir) end,
settings = {}
}
}
local servers = { 'clojure_lsp', 'terraform_lsp', 'zls', 'pyright', 'rust_analyzer', 'ts_ls', 'lua_ls', 'nil_ls', 'gopls', 'bashls'}
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = function(client, bufnr)
navic.attach(client, bufnr)
end,
capabilities = capabilities,
}
end
-- fennel-ls doesn't support navic
lspconfig['fennel-ls'].setup {
on_attach = function(client, bufnr)
-- fennel-ls setup without navic
end,
capabilities = capabilities,
}
-- deprecated pylsp
-- require('lspconfig').pylsp.setup {
-- on_attach = function(client, bufnr)
-- format.on_attach(client)
-- navic.attach(client, bufnr)
-- end,
-- capabilities = capabilities,
-- settings = {
-- pylsp = {
-- configurationSources = { "flake8", "mypy", "black" },
-- plugins = {
-- black = {enabled = true},
-- jedi_signature_help = {enabled = true},
-- jedi_completion = { include_params = true },
-- pylsp_mypy={ enabled = true },
-- pycodestyle={
-- enabled=true,
-- ignore={'E501', 'E231'},
-- maxLineLength=120,
-- },
-- },
-- },
-- },
-- }
require('gitsigns').setup { sign_priority=80 }
-- treesitter
require('nvim-treesitter.configs').setup {
-- parser_install_dir = "~/.local/share/nvim/site/parser/",
-- ensure_installed={'nix', 'clojure', 'python', 'fennel', 'lua', 'html', 'css', 'regex', 'supercollider', 'beancount', 'janet'},
highlight = { enabled = true, additional_vim_regex_highting = true, },
textobjects = { enabled = true },
}
-- 'glsl' needs c++ compiler lol
-- lualine
local navic = require("nvim-navic")
require('lualine').setup {
options = { theme = 'ayu' },
sections = {
lualine_c = {
'filename', { navic.get_location, condition=navic.is_available },
},
lualine_y = {
function()
local msg = 'No Active Lsp'
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
local clients = vim.lsp.get_clients()
if next(clients) == nil then
return msg
end
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name
end
end
return msg
end
},
lualine_x = {'filetype'}
}
}
-- nvim-lint
-- require('lint').linters_by_ft = {
-- markdown = {'vale'},
-- }
-- f_term
local map = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }
map('n', '<TAB>', '<CMD>lua require("FTerm").toggle()<CR>', opts)
map('t', '<TAB>', '<C-\\><C-n><CMD>lua require("FTerm").toggle()<CR>', opts)
-- Custom functions
function update_date()
local time = os.date("%Y-%m-%d %H:%M")
local message = "%update " .. time
local lines = vim.api.nvim_buf_get_lines(0, 0,4,false)
for i=1,4,1 do
if (lines[i]:len() == 0) then
vim.api.nvim_buf_set_lines(0, i-1, i, false, {message, ""})
return
end
end
if (lines[4]:len() ~= 0) then
vim.api.nvim_buf_set_lines(0, 3, 4, false, {message})
end
return
end
vim.api.nvim_create_autocmd(
"BufWritePre",
{ pattern = { "*.wiki" }, callback = update_date}
)
-- set spelling for text files
vim.api.nvim_create_autocmd(
{ "BufRead", "BufNewFile" },
{ pattern = { "*.wiki", "*.txt", "*.md", "*.tex" },
command = "setlocal spell" }
)
vim.api.nvim_create_autocmd(
"FileType",
{ pattern = { "mail" },
command = "setlocal spell" }
)
-- auto session
vim.o.sessionoptions="blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions"
require('auto-session').setup {
log_level = 'error',
auto_session_suppress_dirs = {'~/', '/tmp', '/'},
auto_session_enable_last_session = false,
auto_session_root_dir = vim.fn.stdpath('data').."/sessions/",
auto_session_enabled = true,
auto_save_enabled = nil,
auto_restore_enabled = nil,
auto_session_create_enabled = nil,
}
require("which-key").setup{}
require('leap').set_default_keymaps()
-- supercollider
local scnvim = require 'scnvim'
local map = scnvim.map
local map_expr = scnvim.map_expr
scnvim.setup {
keymaps = {
['<localleader>e'] = map('editor.send_line', {'i', 'n'}),
['<localleader>s'] = map_expr('CmdPeriod.run', {'i', 'n'}),
['<localleader>t'] = {
map('editor.send_block', {'i', 'n'}),
map('editor.send_selection', 'x'),
},
['<CR>'] = map('postwin.toggle'),
['<M-CR>'] = map('postwin.toggle', 'i'),
['<M-L>'] = map('postwin.clear', {'n', 'i'}),
['<C-k>'] = map('signature.show', {'n', 'i'}),
['<F12>'] = map('sclang.hard_stop', {'n', 'x', 'i'}),
['<leader>st'] = map('sclang.start'),
['<leader>sk'] = map('sclang.recompile'),
['<F1>'] = map_expr('s.boot'),
['<F2>'] = map_expr('s.meter'),
}
}
-- You gotta run :SCNvimGenerateAssets for this first
-- require("luasnip").add_snippets("supercollider", require("scnvim/utils").get_snippets())
-- zk
require("zk").setup()
-- vim.api.nvim_set_keymap("n", "<leader>zn", "<Cmd>ZkNew { title = vim.fn.input('Title: ') }<CR>", opts)
-- Open notes.
vim.api.nvim_set_keymap("n", "<leader>zo", "<Cmd>ZkNotes { sort = { 'modified' } }<CR>", opts)
-- Open notes associated with the selected tags.
vim.api.nvim_set_keymap("n", "<leader>zt", "<Cmd>ZkTags<CR>", opts)
local map = vim.api.nvim_set_keymap
-- Search for the notes matching a given query.
vim.api.nvim_set_keymap("n", "<leader>zf", "<Cmd>ZkNotes { sort = { 'modified' }, match = { vim.fn.input('Search: ') } }<CR>", opts)
-- Search for the notes matching the current visual selection.
vim.api.nvim_set_keymap("v", "<leader>zf", ":'<,'>ZkMatch<CR>", opts)
map("n", "<CR>", "<Cmd>lua vim.lsp.buf.definition()<CR>", opts)
-- Create a new note after asking for its title.
-- This overrides the global `<leader>zn` mapping to create the note in the same directory as the current buffer.
-- map("n", "<leader>zn", "<Cmd>ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>", opts)
-- Create a new note in the same directory as the current buffer, using the current selection for title.
-- map("v", "<leader>znt", ":'<,'>ZkNewFromTitleSelection { dir = vim.fn.expand('%:p:h') }<CR>", opts)
-- Create a new note in the same directory as the current buffer, using the current selection for note content and asking for its title.
map("v", "<leader>znc", ":'<,'>ZkNewFromContentSelection { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>", opts)
-- Open notes linking to the current buffer.
map("n", "<leader>zb", "<Cmd>ZkBacklinks<CR>", opts)
-- Alternative for backlinks using pure LSP and showing the source context.
--map('n', '<leader>zb', '<Cmd>lua vim.lsp.buf.references()<CR>', opts)
-- Open notes linked by the current buffer.
map("n", "<leader>zl", "<Cmd>ZkLinks<CR>", opts)
-- Preview a linked note.
map("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
-- Open the code actions for a visual selection.
map("v", "<leader>za", ":'<,'>lua vim.lsp.buf.range_code_action()<CR>", opts)
-- zen mode
require('zen-mode').setup{
window = {
backdrop = 1.0, -- shade the backdrop of the Zen window. Set to 1 to keep the same as Normal
-- height and width can be:
-- * an absolute number of cells when > 1
-- * a percentage of the width / height of the editor when <= 1
-- * a function that returns the width or the height
width = 120, -- width of the Zen window
height = 1, -- height of the Zen window
-- by default, no options are changed for the Zen window
-- uncomment any of the options below, or add other vim.wo options you want to apply
options = {
signcolumn = "no", -- disable signcolumn
number = false, -- disable number column
relativenumber = false, -- disable relative numbers
cursorline = false, -- disable cursorline
cursorcolumn = false, -- disable cursor column
foldcolumn = "0", -- disable fold column
list = false, -- disable whitespace characters
},
},
plugins = {
-- disable some global vim options (vim.o...)
-- comment the lines to not apply the options
options = {
enabled = true,
ruler = false, -- disables the ruler text in the cmd line area
showcmd = false, -- disables the command in the last line of the screen
},
twilight = { enabled = true }, -- enable to start Twilight when zen mode opens
gitsigns = { enabled = false }, -- disables git signs
tmux = { enabled = false }, -- disables the tmux statusline
-- this will change the font size on kitty when in zen mode
-- to make this work, you need to set the following kitty options:
-- - allow_remote_control socket-only
-- - listen_on unix:/tmp/kitty
kitty = {
enabled = true,
font = "+2", -- font size increment
},
},
}
require('twilight').setup{}
-- hologram
require('hologram').setup{
auto_display = false -- WIP automatic markdown image display, may be prone to breaking
}
-- Setup Navigator.nvim
require('Navigator').setup {
disable_on_zoom = true,
mux = 'auto', -- auto-detect tmux
}
-- Set up Navigator.nvim keybindings
vim.keymap.set({'n', 't'}, '<M-h>', '<CMD>NavigatorLeft<CR>')
vim.keymap.set({'n', 't'}, '<M-j>', '<CMD>NavigatorDown<CR>')
vim.keymap.set({'n', 't'}, '<M-k>', '<CMD>NavigatorUp<CR>')
vim.keymap.set({'n', 't'}, '<M-l>', '<CMD>NavigatorRight<CR>')
-- Disable Ctrl+V in nvim so Kitty can handle paste
vim.keymap.set({'n', 'v', 'i'}, '<C-v>', '<Nop>', {noremap = true, silent = true})
-- Pane resizing with Alt+Shift+hjkl (to match tmux)
vim.keymap.set('n', '<M-S-h>', '<Cmd>vertical resize -2<CR>', {silent = true})
vim.keymap.set('n', '<M-S-j>', '<Cmd>resize -2<CR>', {silent = true})
vim.keymap.set('n', '<M-S-k>', '<Cmd>resize +2<CR>', {silent = true})
vim.keymap.set('n', '<M-S-l>', '<Cmd>vertical resize +2<CR>', {silent = true})
EOF
'';
extraPackages = with pkgs // customPlugins; [
# used to compile tree-sitter grammar
python-with-my-packages
nodejs
clojure-lsp
clojure
nil
terraform-lsp
rust-analyzer
clj-kondo
zls
gopls
gcc
pyright
shellcheck
proselint
statix
nodePackages.typescript
nodePackages.typescript-language-server
nodePackages.bash-language-server
luajitPackages.lua-lsp
fennel-ls
nixfmt-rfc-style
shfmt
zk
];
plugins = with pkgs.vimPlugins // customPlugins; [
# ui
lualine-nvim
fzf-vim
neo-tree-nvim
outline-nvim
noice-nvim
nui-nvim
trouble-nvim
neovim-ayu
rainbow_parentheses-vim
vim-surround
vim-devicons
nvim-web-devicons
undotree
telescope-nvim
plenary-nvim
nvim-navic
(nvim-treesitter.withPlugins (p: [ p.nix p.clojure p.python p.fennel p.lua p.html p.css p.regex p.supercollider p.beancount p.markdown p.glsl p.yaml p.toml p.dockerfile p.json ]))
nvim-treesitter-context
my-fterm
barbar-nvim
auto-session
my-marks
which-key-nvim
nvim-peekup
zen-mode-nvim
twilight-nvim
my-lspsaga
vim-dasht
# language
vim-nix
vim-elixir
emmet-vim
csv-vim
direnv-vim
zig-vim
conjure
# kitaab stuff
vimwiki
taskwiki
vim-zettel
hologram-nvim
zk-nvim
# lsp stuff
# nvim-lint
nvim-lspconfig
nvim-cmp
cmp-nvim-lsp
cmp-treesitter
nvim-lsp-ts-utils
cmp-conjure
cmp-buffer
cmp-path
cmp-spell
nvim-autopairs
cmp_luasnip
luasnip
conform-nvim
friendly-snippets
lspkind-nvim
# git stuff
vim-fugitive
gitsigns-nvim
fzf-checkout-vim
# Clojure stuff
# conjure
vim-sexp
vim-sexp-mappings-for-regular-people
fennel-vim
vim-tidal
# experimental
nvim-luapad
scnvim
leap
Navigator-nvim
vim-beancount
# vimtex
# custom
yuck-vim
nvim-parinfer
# vim-processing
];
withPython3 = true;
extraPython3Packages = pkgs: with pkgs; [ tasklib six packaging ];
vimAlias = true;
};
}