revamp of nix organization
This commit is contained in:
parent
01a48ac956
commit
4a4014bf59
20 changed files with 369 additions and 129 deletions
146
nix/home/programs/nvim/default.nix
Normal file
146
nix/home/programs/nvim/default.nix
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
{ pkgs, ... }:
|
||||
let
|
||||
vim-goyo = pkgs.vimUtils.buildVimPlugin {
|
||||
name = "vim-goyo";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "junegunn";
|
||||
repo = "goyo.vim";
|
||||
rev = "6b6ed2734084fdbb6315357ddcaecf9c8e6f143d";
|
||||
sha256 = "1ywlz1hn54kxyp5q0angriaarimq7ys7m6sk6l4x8jr1g2yh0afz";
|
||||
};
|
||||
};
|
||||
|
||||
vim-nix = pkgs.vimUtils.buildVimPlugin {
|
||||
name = "vim-nix";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "LnL7";
|
||||
repo = "vim-nix";
|
||||
rev = "d733cb96707a2a6bdc6102b6d89f947688e0e959";
|
||||
sha256 = "12k2gwm8b1n02361gpjhsldql99yd7qsh80a3lbwc5c5gz5j8jsb";
|
||||
};
|
||||
};
|
||||
|
||||
vim-catppuccino = pkgs.vimUtils.buildVimPlugin {
|
||||
name = "vim-catppuccino";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "Pocco81";
|
||||
repo = "Catppuccino.nvim";
|
||||
rev = "014d8575acdd19ecef4ecb12fc82a2e21794b548";
|
||||
sha256 = "0i0p21jkrx99n3dnm5xvnw8n963c67l4lgl4iwngz0psdzwxphkw";
|
||||
};
|
||||
};
|
||||
in with builtins;
|
||||
{
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
vimAlias = true;
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
vim-sensible
|
||||
vim-startify
|
||||
vim-catppuccino
|
||||
|
||||
vim-elixir
|
||||
alchemist-vim
|
||||
vim-nix
|
||||
vim-javascript
|
||||
vim-json
|
||||
vim-jsx-pretty
|
||||
|
||||
vim-commentary
|
||||
vim-airline
|
||||
{
|
||||
plugin = rainbow;
|
||||
config = ''
|
||||
let g:rainbow_conf = {
|
||||
\ 'guifgs': ['RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3', 'RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3', 'RoyalBlue3', 'DarkOrchid3', 'firebrick3', 'RoyalBlue3', 'SeaGreen3', 'DarkOrchid3', 'firebrick3'],
|
||||
\ 'ctermfgs': ['red', 'brown', 'blue', 'gray', 'green', 'magenta', 'cyan', 'darkred', 'brown', 'darkblue', 'gray', 'darkgreen', 'darkmagenta', 'darkcyan', 'red'],
|
||||
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold']
|
||||
\}
|
||||
let g:rainbow_active = 1
|
||||
'';
|
||||
}
|
||||
vim-signify
|
||||
{
|
||||
plugin = vim-indent-guides;
|
||||
config = ''
|
||||
let g:indent_guides_enable_on_vim_startup = 1
|
||||
let g:indent_guides_start_level = 2
|
||||
'';
|
||||
}
|
||||
vim-surround
|
||||
fugitive
|
||||
{
|
||||
plugin = easymotion;
|
||||
config = ''
|
||||
map / <Plug>(easymotion-sn)
|
||||
omap / <Plug>(easymotion-tn)
|
||||
map n <Plug>(easymotion-next)
|
||||
map N <Plug>(easymotion-prev)
|
||||
let g:EasyMotion_landing_highlight = 0
|
||||
'';
|
||||
}
|
||||
vinegar
|
||||
undotree
|
||||
{
|
||||
plugin = nvim-compe;
|
||||
config = ''
|
||||
set completeopt=menuone,noselect
|
||||
let g:compe = {}
|
||||
let g:compe.enabled = v:true
|
||||
let g:compe.autocomplete = v:true
|
||||
let g:compe.debug = v:false
|
||||
let g:compe.min_length = 1
|
||||
let g:compe.preselect = 'enable'
|
||||
let g:compe.throttle_time = 80
|
||||
let g:compe.source_timeout = 200
|
||||
let g:compe.resolve_timeout = 800
|
||||
let g:compe.incomplete_delay = 400
|
||||
let g:compe.max_abbr_width = 100
|
||||
let g:compe.max_kind_width = 100
|
||||
let g:compe.max_menu_width = 100
|
||||
let g:compe.documentation = v:true
|
||||
|
||||
let g:compe.source = {}
|
||||
let g:compe.source.path = v:true
|
||||
let g:compe.source.buffer = v:true
|
||||
let g:compe.source.calc = v:true
|
||||
let g:compe.source.nvim_lsp = v:true
|
||||
let g:compe.source.nvim_lua = v:true
|
||||
let g:compe.source.vsnip = v:true
|
||||
let g:compe.source.ultisnips = v:true
|
||||
let g:compe.source.luasnip = v:true
|
||||
let g:compe.source.emoji = v:true
|
||||
'';
|
||||
}
|
||||
vim-goyo
|
||||
{
|
||||
plugin = nvim-lspconfig;
|
||||
config = ''
|
||||
lua << EOF
|
||||
${readFile (
|
||||
pkgs.substituteAll {
|
||||
src = ./nvim-lspconfig.lua;
|
||||
# since both of these are used for actually configuring the system,
|
||||
# we'll probably always want them around.
|
||||
lua_ls = pkgs.sumneko-lua-language-server;
|
||||
rnix_lsp = pkgs.rnix-lsp;
|
||||
}
|
||||
) }
|
||||
EOF
|
||||
'';
|
||||
}
|
||||
{
|
||||
plugin = telescope-nvim;
|
||||
config = ''
|
||||
nnoremap <leader>ff <cmd>lua require('telescope.builtin').find_files()<cr>
|
||||
nnoremap <leader>fg <cmd>lua require('telescope.builtin').live_grep()<cr>
|
||||
nnoremap <leader>fb <cmd>lua require('telescope.builtin').buffers()<cr>
|
||||
nnoremap <leader>fh <cmd>lua require('telescope.builtin').help_tags()<cr>
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
extraConfig = readFile ./init.vim;
|
||||
};
|
||||
|
||||
}
|
||||
86
nix/home/programs/nvim/init.vim
Normal file
86
nix/home/programs/nvim/init.vim
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
filetype plugin indent on
|
||||
|
||||
" Indent guides
|
||||
|
||||
" let netrw look like NERDTree
|
||||
let g:netrw_liststyle = 3
|
||||
set nobackup
|
||||
set noswapfile
|
||||
set pastetoggle=<F2>
|
||||
set nowrap
|
||||
|
||||
set background=dark
|
||||
colorscheme catppuccino
|
||||
|
||||
set nocompatible
|
||||
set number relativenumber
|
||||
set numberwidth=1
|
||||
set cursorline
|
||||
set cursorcolumn
|
||||
set ruler
|
||||
set list
|
||||
set listchars=tab:>-,trail:-,extends:>,precedes:<,nbsp:+,eol:$
|
||||
set matchpairs+=<:>
|
||||
set ts=2
|
||||
set shiftwidth=2
|
||||
set expandtab
|
||||
|
||||
" Open new split panes to right and bottom, which feels more natural
|
||||
set splitbelow
|
||||
set splitright
|
||||
|
||||
""" Searching and Patterns
|
||||
set ignorecase
|
||||
set smartcase
|
||||
set smarttab
|
||||
set hlsearch
|
||||
" Add the g flag to search/replace by default
|
||||
set gdefault
|
||||
|
||||
"recalculate the trailing whitespace warning when idle, and after saving
|
||||
autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning
|
||||
|
||||
" strip trailing whitespace
|
||||
autocmd BufWritePre * :%s/\s\+$//e
|
||||
|
||||
""" Handy remaps
|
||||
noremap ; :
|
||||
inoremap jj <Esc>
|
||||
map <silent> <leader>V :source ~/.config/nvim/init.vim<CR>:filetype detect<CR>:exe ":echo 'vimrc reloaded'"<CR>
|
||||
map \q :q<CR>
|
||||
map \w :w<CR>
|
||||
noremap Q <nop>
|
||||
|
||||
""" Esperanto digraphs (for use with ctrl-k)
|
||||
:digraph Cx 264
|
||||
:digraph cx 265
|
||||
:digraph Gx 284
|
||||
:digraph gx 285
|
||||
:digraph Hx 292
|
||||
:digraph hx 293
|
||||
:digraph Jx 308
|
||||
:digraph jx 309
|
||||
:digraph Sx 348
|
||||
:digraph sx 349
|
||||
:digraph Ux 364
|
||||
:digraph ux 365
|
||||
|
||||
""" Terminal mode remaps
|
||||
tnoremap <Esc> <C-\><C-n>
|
||||
nnoremap <leader>o :below 10sp term://$SHELL<cr>i
|
||||
|
||||
" Quicker window movement
|
||||
nnoremap <C-j> <C-w>j
|
||||
nnoremap <C-k> <C-w>k
|
||||
nnoremap <C-h> <C-w>h
|
||||
nnoremap <C-l> <C-w>l
|
||||
|
||||
" Don’t reset cursor to start of line when moving around.
|
||||
set nostartofline
|
||||
" minimal number of lines to keep above/below cursorline
|
||||
set scrolloff=10
|
||||
|
||||
" Local overrides?
|
||||
if filereadable($HOME . "/.vimrc.local")
|
||||
source ~/.vimrc.local
|
||||
endif
|
||||
161
nix/home/programs/nvim/nvim-lspconfig.lua
Normal file
161
nix/home/programs/nvim/nvim-lspconfig.lua
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
local nvim_lsp = require("lspconfig")
|
||||
|
||||
local format_async = function(err, _, result, _, bufnr)
|
||||
if err ~= nil or result == nil then return end
|
||||
if not vim.api.nvim_buf_get_option(bufnr, "modified") then
|
||||
local view = vim.fn.winsaveview()
|
||||
vim.lsp.util.apply_text_edits(result, bufnr)
|
||||
vim.fn.winrestview(view)
|
||||
if bufnr == vim.api.nvim_get_current_buf() then
|
||||
vim.api.nvim_command("noautocmd :update")
|
||||
end
|
||||
end
|
||||
end
|
||||
vim.lsp.handlers["textDocument/formatting"] = format_async
|
||||
|
||||
local on_attach = function(client, bufnr)
|
||||
local buf_map = vim.api.nvim_buf_set_keymap
|
||||
|
||||
vim.cmd("command! LspDef lua vim.lsp.buf.definition()")
|
||||
vim.cmd("command! LspFormatting lua vim.lsp.buf.formatting()")
|
||||
vim.cmd("command! LspCodeAction lua vim.lsp.buf.code_action()")
|
||||
vim.cmd("command! LspHover lua vim.lsp.buf.hover()")
|
||||
vim.cmd("command! LspRename lua vim.lsp.buf.rename()")
|
||||
vim.cmd("command! LspOrganize lua lsp_organize_imports()")
|
||||
vim.cmd("command! LspRefs lua vim.lsp.buf.references()")
|
||||
vim.cmd("command! LspTypeDef lua vim.lsp.buf.type_definition()")
|
||||
vim.cmd("command! LspImplementation lua vim.lsp.buf.implementation()")
|
||||
vim.cmd("command! LspDiagPrev lua vim.lsp.diagnostic.goto_prev()")
|
||||
vim.cmd("command! LspDiagNext lua vim.lsp.diagnostic.goto_next()")
|
||||
vim.cmd("command! LspDiagLine lua vim.lsp.diagnostic.show_line_diagnostics()")
|
||||
vim.cmd("command! LspSignatureHelp lua vim.lsp.buf.signature_help()")
|
||||
|
||||
buf_map(bufnr, "n", "gd", ":LspDef<CR>", {silent = true})
|
||||
buf_map(bufnr, "n", "gr", ":LspRename<CR>", {silent = true})
|
||||
buf_map(bufnr, "n", "gR", ":LspRefs<CR>", {silent = true})
|
||||
buf_map(bufnr, "n", "gy", ":LspTypeDef<CR>", {silent = true})
|
||||
buf_map(bufnr, "n", "K", ":LspHover<CR>", {silent = true})
|
||||
buf_map(bufnr, "n", "gs", ":LspOrganize<CR>", {silent = true})
|
||||
buf_map(bufnr, "n", "[a", ":LspDiagPrev<CR>", {silent = true})
|
||||
buf_map(bufnr, "n", "]a", ":LspDiagNext<CR>", {silent = true})
|
||||
buf_map(bufnr, "n", "ga", ":LspCodeAction<CR>", {silent = true})
|
||||
buf_map(bufnr, "n", "<Leader>a", ":LspDiagLine<CR>", {silent = true})
|
||||
buf_map(bufnr, "i", "<C-x><C-x>", "<cmd> LspSignatureHelp<CR>", {silent = true})
|
||||
|
||||
if client.resolved_capabilities.document_formatting then
|
||||
vim.api.nvim_exec([[
|
||||
augroup LspAutocommands
|
||||
autocmd! * <buffer>
|
||||
autocmd BufWritePost <buffer> LspFormatting
|
||||
augroup END
|
||||
]], true)
|
||||
end
|
||||
end
|
||||
|
||||
nvim_lsp.diagnosticls.setup {
|
||||
on_attach = on_attach;
|
||||
filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'css', 'scss', 'markdown', 'pandoc' },
|
||||
init_options = {
|
||||
linters = {
|
||||
eslint = {
|
||||
command = 'eslint',
|
||||
rootPatterns = { '.git' },
|
||||
debounce = 100,
|
||||
args = { '--stdin', '--stdin-filename', '%filepath', '--format', 'json' },
|
||||
sourceName = 'eslint',
|
||||
parseJson = {
|
||||
errorsRoot = '[0].messages',
|
||||
line = 'line',
|
||||
column = 'column',
|
||||
endLine = 'endLine',
|
||||
endColumn = 'endColumn',
|
||||
message = '[eslint] ${message} [${ruleId}]',
|
||||
security = 'severity'
|
||||
},
|
||||
securities = {
|
||||
[2] = 'error',
|
||||
[1] = 'warning'
|
||||
}
|
||||
},
|
||||
markdownlint = {
|
||||
command = 'markdownlint',
|
||||
rootPatterns = { '.git' },
|
||||
isStderr = true,
|
||||
debounce = 100,
|
||||
args = { '--stdin' },
|
||||
offsetLine = 0,
|
||||
offsetColumn = 0,
|
||||
sourceName = 'markdownlint',
|
||||
securities = {
|
||||
undefined = 'hint'
|
||||
},
|
||||
formatLines = 1,
|
||||
formatPattern = {
|
||||
'^.*:(\\d+)\\s+(.*)$',
|
||||
{
|
||||
line = 1,
|
||||
column = -1,
|
||||
message = 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
filetypes = {
|
||||
javascript = 'eslint',
|
||||
javascriptreact = 'eslint',
|
||||
typescript = 'eslint',
|
||||
typescriptreact = 'eslint',
|
||||
markdown = 'markdownlint',
|
||||
pandoc = 'markdownlint'
|
||||
},
|
||||
formatters = {
|
||||
prettier = {
|
||||
command = 'prettier',
|
||||
args = { '--stdin-filepath', '%filename' }
|
||||
}
|
||||
},
|
||||
formatFiletypes = {
|
||||
css = 'prettier',
|
||||
javascript = 'prettier',
|
||||
javascriptreact = 'prettier',
|
||||
json = 'prettier',
|
||||
scss = 'prettier',
|
||||
typescript = 'prettier',
|
||||
typescriptreact = 'prettier'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nvim_lsp.elmls.setup{
|
||||
on_attach = on_attach;
|
||||
}
|
||||
nvim_lsp.tsserver.setup {
|
||||
on_attach = function(client)
|
||||
-- Avoid conflict with prettier and eslint
|
||||
client.resolved_capabilities.document_formatting = false
|
||||
on_attach(client)
|
||||
end
|
||||
}
|
||||
nvim_lsp.elixirls.setup{
|
||||
cmd = { "elixir-ls" };
|
||||
on_attach = on_attach;
|
||||
}
|
||||
nvim_lsp.rnix.setup{
|
||||
cmd = { "@rnix_lsp@/bin/rnix-lsp" };
|
||||
on_attach = on_attach;
|
||||
}
|
||||
nvim_lsp.rust_analyzer.setup{
|
||||
on_attach = on_attach;
|
||||
}
|
||||
|
||||
nvim_lsp.sumneko_lua.setup{
|
||||
cmd = { "@lua_ls@/bin/lua-language-server" };
|
||||
on_attach = on_attach;
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { 'vim' }
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue