helm/users/profiles/nvim/default.nix

780 lines
30 KiB
Nix
Raw Normal View History

2022-04-11 01:58:58 -07:00
{ 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=";
};
};
lsp-format = pkgs.vimUtils.buildVimPlugin {
name = "lsp-format";
src = pkgs.fetchFromGitHub {
owner = "lukas-reineke";
repo = "lsp-format.nvim";
rev = "84e117b99bb2bc0d0c8122e2b256046f046f8aff";
sha256 = "rs3NTZwWdsmBGXnrgUeVxUiNjbN/ULxJHifPYJD9mT4=";
};
};
nvim-luapad = pkgs.vimUtils.buildVimPluginFrom2Nix {
name = "nvim-luapad";
src = pkgs.fetchFromGitHub {
owner = "rafcamlet";
repo = "nvim-luapad";
rev = "9815e2659ce8e2ef4b55e401531cf09b6423e0ea";
sha256 = "gMaS5YFi3+gmUIfkCMEt9vhm8XSgv54Cquv5+WCWeTo=";
};
};
leap = pkgs.vimUtils.buildVimPluginFrom2Nix {
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-lualine-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "lualine.nvim";
version = "2022-05-13";
src = pkgs.fetchFromGitHub {
owner = "nvim-lualine";
repo = "lualine.nvim";
rev = "a4e4517ac32441dd92ba869944741f0b5f468531";
sha256 = "18q935aicddai7j99ln61wz1di6lhwzs11x8fxgq704kfap1l2fj";
};
meta.homepage = "https://github.com/nvim-lualine/lualine.nvim/";
};
my-which-key-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
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/";
};
my-conjure = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "conjure";
version = "2022-05-04";
src = pkgs.fetchFromGitHub {
owner = "olical";
repo = "conjure";
rev = "2e7f449d06753f2996e186954e96afc60edd5862";
sha256 = "ZV0vPYiZI5/3Isw2l7rrLuiO+kA9G0vrA6OxHFkLTFw=";
};
};
2022-08-02 04:24:53 -07:00
scnvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "scnvim";
version = "2022-06-04";
src = pkgs.fetchFromGitHub {
owner = "davidgranstrom";
repo = "scnvim";
rev = "746cc0db820d02a9c36b8f9ba2eac9725fa73107";
sha256 = "kvSwS6FNUY2Ue84NhWLLcm0ldLMSp4WqQ7s6TUoX6Cc=";
};
};
2022-04-11 01:58:58 -07:00
};
my-python-packages = python-packages: with python-packages; [
tasklib
pynvim
six
python-lsp-server
python-lsp-black
pylsp-mypy
2022-04-11 01:58:58 -07:00
black
# other python packages you want
];
python-with-my-packages = pkgs.python3.withPackages my-python-packages;
in
{
home.sessionVariables.EDITOR = "nvim";
home.shellAliases = {
2022-04-11 01:58:58 -07:00
k = "cd ~/kitaab/vimwiki; vim -c :VimwikiIndex; cd $OLDPWD";
kz = "cd ~/kitaab/vimwiki; vim -c :VimwikiIndex -c :ZettelNew; 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
'';
2022-04-11 01:58:58 -07:00
#environment.systemPackages = with customPlugins; [ tidal ];
programs.neovim = {
2022-04-11 01:58:58 -07:00
enable = true;
extraConfig = ''
" so our custom files still get included
set runtimepath+=/home/anish/.config/nvim/
2022-04-11 01:58:58 -07:00
set tabstop=2
set showmatch
set shiftwidth=2
set noexpandtab
set autoindent
set undofile
set signcolumn=auto:4
2022-04-23 21:55:24 -07:00
set title
2022-04-11 01:58:58 -07:00
2022-04-23 21:55:24 -07:00
" set foldmethod=indent " fold based on indent
2022-04-11 01:58:58 -07:00
set number
set nocompatible
set relativenumber
set showtabline=2
set noexpandtab
set autowriteall
set list lcs=tab:\|\
filetype plugin on
2022-04-23 21:55:24 -07:00
" include - in word to move across easier in lisp / clojure
set iskeyword+=-
2022-04-11 01:58:58 -07:00
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=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
" highlight row
set cursorline
2022-04-11 01:58:58 -07:00
let mapleader = "\<Space>"
let maplocalleader = ","
2022-04-11 01:58:58 -07:00
" window
2022-04-23 21:55:24 -07:00
nmap <leader>wh :topleft vnew<CR>
2022-04-11 01:58:58 -07:00
nmap <leader>wl :botright vnew<CR>
2022-04-23 21:55:24 -07:00
nmap <leader>wk :topleft new<CR>
2022-04-11 01:58:58 -07:00
nmap <leader>wj :botright new<CR>
" tabs
nmap <leader>rt :retab!<CR>
vmap <leader>rt :retab!<CR>
" 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")<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"
" 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"
2022-05-13 05:29:35 -07:00
let g:conjure#filetype#fennel = "conjure.client.fennel.stdio"
2022-04-11 01:58:58 -07:00
let g:rainbow_active = 0
autocmd BufReadPost,BufNewFile c,clj,cljs RainbowParenthesesToggleAll
" general commands
map <leader>t :NERDTreeToggle<CR>
map <leader>s :w<CR>
2022-04-26 03:06:44 -07:00
map <leader>q :q<CR>
2022-04-11 01:58:58 -07:00
map <leader>r :RainbowParenthesesToggleAll<CR>
map <leader><BS> :noh<CR>
map Q <Nop>
2022-04-11 01:58:58 -07:00
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>
" barbar
nnoremap <silent> gT :BufferPrevious<CR>
nnoremap <silent> gt :BufferNext<CR>
nnoremap <silent> gj :BufferPick<CR>
nnoremap <silent> gq :BufferClose<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
2022-05-14 07:25:21 -07:00
map <leader>cz :VimwikiIndex<CR>:ZettelNew
2022-04-11 01:58:58 -07:00
map <leader>zs :ZettelSearch<CR>
map <leader>zo :ZettelOpen<CR>
map <leader>zn :ZettelNew<CR>
map <leader>zf :Telescope oldfiles only_cwd=true<CR>
map <leader>wt :VimwikiMakeTomorrowDiaryNote
map <leader>wd :VimwikiMakeYesterdayDiaryNote
2022-04-22 08:46:55 -07:00
map <leader>zd :Goyo<CR>:lua require('cmp').setup.buffer { enabled = false }<CR>
2022-04-11 01:58:58 -07:00
let g:vimwiki_list = [{ 'path': '~/kitaab/vimwiki', 'auto_tags': 1, 'auto_diary_index': 1, 'auto_generate_links': 1 }]
2022-04-24 05:46:41 -07:00
let g:sync_taskwarrior = 0
2022-04-22 08:15:42 -07:00
let g:zettel_format = "%y%m%d-%H%M"
2022-08-02 04:24:53 -07:00
let g:vimwiki_list = [{'path': '~/kitaab/vimwiki', 'nested_syntaxes': {'python': 'python', 'c++': 'cpp', 'nix': 'nix', 'bash': 'sh'}}]
2022-04-11 01:58:58 -07:00
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>vd :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 rim.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>
nnoremap <leader>va :lua require('telescope.builtin').lsp_code_actions(require('telescope.themes').get_cursor())<cr>
" dashboard
let g:dashboard_custom_header = [
\' ',
2022-05-13 05:31:21 -07:00
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\' ',
\]
2022-05-14 07:25:21 -07:00
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"]
2022-05-14 07:25:21 -07:00
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' }
\ }
2022-08-02 05:27:40 -07:00
let g:scnvim_snippet_format = "luasnip"
2022-04-11 01:58:58 -07:00
" lua config
lua <<EOF
2022-06-16 18:25:22 -07:00
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
2022-04-11 01:58:58 -07:00
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.api.nvim_set_keymap('n', '<leader>vt', ':call v:lua.toggle_diagnostics()<CR>', {noremap = true, silent = true})
-- autopairs
require('nvim-autopairs').setup{}
2022-06-15 02:26:23 -07:00
-- marks
require('marks').setup{}
2022-04-11 01:58:58 -07:00
-- 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")
2022-06-15 02:34:30 -07:00
local lspkind = require("lspkind")
2022-04-11 01:58:58 -07:00
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 = {
2022-06-15 02:26:23 -07:00
format = lspkind.cmp_format({
2022-06-15 02:34:30 -07:00
mode = 'symbol_text',
maxwidth = 50,
2022-06-15 02:26:23 -07:00
-- old format
-- format = function(entry, vim_item)
-- -- fancy icons and a name of kind
-- vim_item.kind = require("lspkind").presets.default[vim_item.kind] ..
-- " " .. vim_item.kind
-- -- set a name for each source
-- vim_item.menu = ({
-- buffer = "[Buffer]",
-- nvim_lsp = "[LSP]",
-- look = "[Look]",
-- path = "[Path]",
-- spell = "[Spell]",
-- calc = "[Calc]",
-- })[entry.source.name]
-- return vim_item
-- end
2022-06-15 02:34:30 -07:00
})
2022-04-11 01:58:58 -07:00
},
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
}),
2022-04-23 21:55:24 -07:00
["<Tab>"] = cmp.mapping(function(fallback)
2022-04-11 01:58:58 -07:00
if cmp.visible() then
2022-04-23 21:55:24 -07:00
cmp.select_next_item()
2022-04-11 01:58:58 -07:00
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
2022-04-23 21:55:24 -07:00
fallback()
2022-04-11 01:58:58 -07:00
end
end, {"i", "s"}),
2022-04-23 21:55:24 -07:00
["<S-Tab>"] = cmp.mapping(function(fallback)
2022-04-11 01:58:58 -07:00
if cmp.visible() then
2022-04-23 21:55:24 -07:00
cmp.select_prev_item()
2022-04-11 01:58:58 -07:00
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
2022-04-23 21:55:24 -07:00
else
fallback()
2022-04-11 01:58:58 -07:00
end
end, { "i", "s" }),
},
2022-06-15 02:26:23 -07:00
snippet = {
expand = function(args)
require'luasnip'.lsp_expand(args.body)
end
},
2022-04-11 01:58:58 -07:00
sources = {
{name = 'buffer'}, {name = 'nvim_lsp'},
{name = "look"}, {name = "path"},
{name = "calc"}, {name = "spell"},
2022-08-02 05:27:40 -07:00
{name = 'cmp-conjure'}, {name = "luasnip"},
{name = 'tags'}
2022-04-11 01:58:58 -07:00
},
completion = {completeopt = 'menu,menuone,noinsert'}
}
cmp.event:on( 'confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = ' ' } }))
2022-06-15 02:26:23 -07:00
require("luasnip.loaders.from_vscode").lazy_load()
2022-04-11 01:58:58 -07:00
-- null-ls
local null_ls = require "null-ls"
local pyright = {
cmd = { "pyright" },
filetypes = { "python", },
debounce = 250,
debug = false,
default_timeout = 5000,
args = { "-p", "$FILENAME", "--skipunannotated" }
}
local sources = {
pyright,
null_ls.builtins.code_actions.statix,
null_ls.builtins.diagnostics.shellcheck,
-- null_ls.builtins.diagnostics.clj_kondo,
-- null_ls.builtins.formatting.black,
null_ls.builtins.code_actions.proselint,
-- null_ls.builtins.diagnostics.mypy,
}
2022-04-11 01:58:58 -07:00
-- Setup lspconfig
require("lsp-format").setup {}
require("nvim-navic").setup {}
local format = require("lsp-format")
local navic = require("nvim-navic")
2022-04-11 01:58:58 -07:00
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
local lspconfig = require('lspconfig')
2022-08-02 04:24:53 -07:00
local servers = { 'clojure_lsp', 'terraform_lsp', 'zls' }
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = function(client, bufnr)
format.on_attach(client)
navic.attach(client, bufnr)
end,
capabilities = capabilities,
}
end
2022-07-18 07:56:45 -07:00
-- rnix doesn't support gps
require('lspconfig').rnix.setup {
on_attach = function(client, bufnr)
format.on_attach(client)
end,
capabilities = capabilities,
}
require('lspconfig').pylsp.setup {
on_attach = function(client, bufnr)
format.on_attach(client)
navic.attach(client, bufnr)
end,
capabilities = capabilities,
2022-04-11 01:58:58 -07:00
settings = {
pylsp = {
configurationSources = { "flake8", "mypy", "black" },
2022-04-11 01:58:58 -07:00
plugins = {
black = {enabled = true},
2022-04-11 01:58:58 -07:00
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
2022-07-08 08:28:37 -07:00
require('nvim-treesitter.configs').setup {
2022-07-09 03:20:00 -07:00
ensure_installed={'nix', 'clojure', 'python', 'fennel', 'lua', 'html', 'css', 'regex', 'supercollider'},
highlight = { enabled = true, additional_vim_regex_highting = true, },
2022-07-08 08:28:37 -07:00
textobjects = { enabled = true },
}
2022-04-22 08:46:55 -07:00
-- 'glsl' needs c++ compiler lol
2022-04-11 01:58:58 -07:00
-- lualine
local navic = require("nvim-navic")
2022-04-11 01:58:58 -07:00
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_active_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'}
2022-04-11 01:58:58 -07:00
}
}
2022-04-11 01:58:58 -07:00
-- nvim-lint
-- require('lint').linters_by_ft = {
-- markdown = {'vale'},
-- }
2022-04-11 01:58:58 -07:00
-- 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)
2022-04-11 01:58:58 -07:00
map('t', '<A-i>', '<C-\\><C-n><CMD>lua require("FTerm").toggle()<CR>', opts)
2022-04-23 21:55:24 -07:00
-- 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" }
)
2022-07-13 09:27:44 -07:00
vim.api.nvim_create_autocmd(
"FileType",
{ pattern = { "mail" },
command = "setlocal spell" }
)
2022-06-15 02:26:23 -07:00
-- auto session
require('auto-session').setup {
log_level = 'info',
2022-06-15 02:34:30 -07:00
auto_session_suppress_dirs = {'~/'}
2022-06-15 02:26:23 -07:00
}
vim.o.sessionoptions="blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal"
require("which-key").setup{}
require('leap').set_default_keymaps()
2022-08-02 05:27:40 -07:00
-- supercollider
2022-08-09 08:33:20 -07:00
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'}),
2022-08-13 19:25:24 -07:00
['<localleader>s'] = map_expr('CmdPeriod.run', {'i', 'n'}),
2022-08-09 08:33:20 -07:00
['<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'),
}
}
-- require("luasnip").add_snippets("supercollider", require("scnvim/utils").get_snippets())
2022-04-11 01:58:58 -07:00
EOF
'';
extraPackages = with pkgs // customPlugins; [
# used to compile tree-sitter grammar
tree-sitter
python-with-my-packages
nodejs
clojure-lsp
rnix-lsp
terraform-lsp
clj-kondo
2022-08-02 04:24:53 -07:00
zls
2022-04-23 21:55:24 -07:00
gcc
nodePackages.pyright
shellcheck
proselint
statix
2022-04-11 01:58:58 -07:00
# installs different langauge servers for neovim-lsp
# have a look on the link below to figure out the ones for your languages
# https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md
nodePackages.typescript
nodePackages.typescript-language-server
];
plugins = with pkgs.vimPlugins // customPlugins; [
2022-06-15 02:26:23 -07:00
# ui
2022-04-11 01:58:58 -07:00
fzf-vim
nerdtree
neovim-ayu
goyo-vim
rainbow_parentheses-vim
vim-surround
vim-devicons
nvim-web-devicons
vim-peekaboo
undotree
telescope-nvim
plenary-nvim
nvim-gps
nvim-treesitter
nvim-treesitter-context
FTerm-nvim
barbar-nvim
2022-06-15 02:26:23 -07:00
auto-session
marks-nvim
# language
vim-nix
vim-elixir
emmet-vim
csv-vim
direnv-vim
2022-08-02 04:24:53 -07:00
zig-vim
2022-04-11 01:58:58 -07:00
# kitaab stuff
vimwiki
taskwiki
vim-zettel
# lsp stuff
# nvim-lint
null-ls-nvim
2022-04-11 01:58:58 -07:00
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
lsp-format
2022-06-15 02:26:23 -07:00
friendly-snippets
lspkind-nvim
2022-04-11 01:58:58 -07:00
# git stuff
vim-fugitive
gitsigns-nvim
fzf-checkout-vim
# Clojure stuff
# conjure
2022-04-11 01:58:58 -07:00
vim-sexp
vim-sexp-mappings-for-regular-people
2022-05-13 05:29:35 -07:00
fennel-vim
2022-04-11 01:58:58 -07:00
vim-tidal
2022-07-09 03:20:00 -07:00
# experimental
nvim-luapad
nvim-navic
2022-08-02 04:24:53 -07:00
scnvim
leap
# TODO break with nvim 0.8.0
# these are here until i upgrade my nixos channnel in the flake
my-which-key-nvim
my-lualine-nvim
my-conjure
2022-04-11 01:58:58 -07:00
# vim-processing
];
withPython3 = true;
extraPython3Packages = pkgs: with pkgs; [ tasklib six ];
vimAlias = true;
};
}
2022-04-19 00:56:05 -07:00