feat: rearrange home-manager modules
This commit is contained in:
parent
89f6ab94b4
commit
58eae1d229
21 changed files with 44 additions and 30 deletions
105
home/editors/coc.vim
Normal file
105
home/editors/coc.vim
Normal file
|
@ -0,0 +1,105 @@
|
|||
" 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
|
||||
|
||||
" Use tab for trigger completion with characters ahead and navigate.
|
||||
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
|
||||
inoremap <silent><expr> <TAB>
|
||||
\ pumvisible() ? "\<C-n>" :
|
||||
\ <SID>check_back_space() ? "\<TAB>" :
|
||||
\ coc#refresh()
|
||||
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
||||
|
||||
function! s:check_back_space() abort
|
||||
let col = col('.') - 1
|
||||
return !col || getline('.')[col - 1] =~# '\s'
|
||||
endfunction
|
||||
|
||||
" Use <c-space> to trigger completion.
|
||||
inoremap <silent><expr> <c-space> coc#refresh()
|
||||
|
||||
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
|
||||
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
|
||||
|
||||
" Use `[g` and `]g` to navigate diagnostics
|
||||
nmap <silent> [g <Plug>(coc-diagnostic-prev)
|
||||
nmap <silent> ]g <Plug>(coc-diagnostic-next)
|
||||
|
||||
" Remap keys for gotos
|
||||
nmap <silent> gd <Plug>(coc-definition)
|
||||
nmap <silent> gy <Plug>(coc-type-definition)
|
||||
nmap <silent> gi <Plug>(coc-implementation)
|
||||
nmap <silent> gr <Plug>(coc-references)
|
||||
|
||||
" Use K to show documentation in preview window
|
||||
nnoremap <silent> K :call <SID>show_documentation()<CR>
|
||||
|
||||
function! s:show_documentation()
|
||||
if (index(['vim','help'], &filetype) >= 0)
|
||||
execute 'h '.expand('<cword>')
|
||||
else
|
||||
call CocAction('doHover')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Highlight symbol under cursor on CursorHold
|
||||
autocmd CursorHold * silent call CocActionAsync('highlight')
|
||||
|
||||
" Remap for rename current word
|
||||
nmap <leader>rn <Plug>(coc-rename)
|
||||
|
||||
" Remap for format selected region
|
||||
xmap <leader>f <Plug>(coc-format-selected)
|
||||
nmap <leader>f <Plug>(coc-format-selected)
|
||||
|
||||
augroup mygroup
|
||||
autocmd!
|
||||
" Setup formatexpr specified filetype(s).
|
||||
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
|
||||
" Update signature help on jump placeholder
|
||||
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
|
||||
augroup end
|
||||
|
||||
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
|
||||
xmap <leader>a <Plug>(coc-codeaction-selected)
|
||||
nmap <leader>a <Plug>(coc-codeaction-selected)
|
||||
|
||||
" Remap for do codeAction of current line
|
||||
nmap <leader>ac <Plug>(coc-codeaction)
|
||||
" Fix autofix problem of current line
|
||||
nmap <leader>qf <Plug>(coc-fix-current)
|
||||
|
||||
" Create mappings for function text object, requires document symbols feature of languageserver.
|
||||
xmap if <Plug>(coc-funcobj-i)
|
||||
xmap af <Plug>(coc-funcobj-a)
|
||||
omap if <Plug>(coc-funcobj-i)
|
||||
omap af <Plug>(coc-funcobj-a)
|
||||
|
||||
" Use `:Format` to format current buffer
|
||||
command! -nargs=0 Format :call CocAction('format')
|
||||
|
||||
" Use `:Fold` to fold current buffer
|
||||
command! -nargs=? Fold :call CocAction('fold', <f-args>)
|
||||
|
||||
" use `:OR` for organize import of current buffer
|
||||
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
|
||||
|
||||
" Using CocList
|
||||
" Show all diagnostics
|
||||
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
|
||||
" Manage extensions
|
||||
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
|
||||
" Show commands
|
||||
nnoremap <silent> <space>c :<C-u>CocList commands<cr>
|
||||
" Find symbol of current document
|
||||
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
|
||||
" Search workspace symbols
|
||||
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
|
||||
" Do default action for next item.
|
||||
nnoremap <silent> <space>j :<C-u>CocNext<CR>
|
||||
" Do default action for previous item.
|
||||
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
|
||||
" Resume latest coc list
|
||||
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
|
33
home/editors/default.nix
Normal file
33
home/editors/default.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./neovim.nix
|
||||
./emacs.nix
|
||||
./vscode.nix
|
||||
];
|
||||
|
||||
home.packages = with pkgs; [
|
||||
fzf
|
||||
ripgrep
|
||||
];
|
||||
|
||||
home.sessionVariables = with pkgs; {
|
||||
EDITOR = "nvim";
|
||||
FZF_DEFAULT_COMMAND = "${ripgrep}/bin/rg --files --hidden";
|
||||
};
|
||||
|
||||
home.file.".editorconfig".text = ''
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
insert_final_newline = false
|
||||
trim_trailing_whitespace = false
|
||||
'';
|
||||
}
|
6
home/editors/emacs.nix
Normal file
6
home/editors/emacs.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
services.emacs.enable = true;
|
||||
programs.emacs.enable = true;
|
||||
}
|
108
home/editors/init.vim
Normal file
108
home/editors/init.vim
Normal file
|
@ -0,0 +1,108 @@
|
|||
" set shell=/bin/sh
|
||||
|
||||
colorscheme gruvbox
|
||||
let g:gruvbox_number_column = 'bg1'
|
||||
|
||||
let g:startify_bookmarks = [
|
||||
\ '~/dev/fitnesspilot',
|
||||
\ '~/dev/fitnesspilot/clients/fitnesspilot-web',
|
||||
\ '~/dev/fitnesspilot/clients/fitnesspilot-preregistration',
|
||||
\ '~/dev/fitnesspilot/microservices',
|
||||
\ '~/dev/fitnesspilot/microservices/usermanagement',
|
||||
\ '~/dev/fitnesspilot/microservices/calendar',
|
||||
\ '~/dev/fitnesspilot/microservices/activities',
|
||||
\ '~/dev/fitnesspilot/microservices/coachtasks',
|
||||
\ '~/dev/fitnesspilot/microservices/notifications',
|
||||
\ '~/dev/fitnesspilot/microservices/googlefitimport',
|
||||
\ '~/dev/fitnesspilot/microservices/devel',
|
||||
\ '~/dev/fitnesspilot/microservices/job',
|
||||
\ '~/dev/fitnesspilot/common/APIModel',
|
||||
\ '~/dev/fitnesspilot/common/CommonModel',
|
||||
\ '~/dev/fitnesspilot/common/CommonDomain',
|
||||
\ '~/dev/fitnesspilot/common/CosmosDBStore',
|
||||
\ '~/dev/fitnesspilot/common/IntegrationTestBase',
|
||||
\ '~/dev/fitnesspilot/common/MicroserviceUtils',
|
||||
\ '~/dev/fitnesspilot/common/Utils',
|
||||
\ '~/dev/fitnesspilot/common/FitnesspilotMathCore',
|
||||
\ '~/dev/fitnesspilot/ops/ops',
|
||||
\ '~/dev/fitnesspilot/ops/kube-dotnet',
|
||||
\ '~/dev/fitnesspilot/wiki',
|
||||
\ '~/dev/fitnesspilot/templates',
|
||||
\ '~/dev/fitnesspilot/tools/fitnesspilot-masterdata',
|
||||
\ '~/dev/fitnesspilot/tools/fitnesspilot-load-tests',
|
||||
\ '~/dev/carepal/carepal-app',
|
||||
\ '~/dev/carepal/carepal-server',
|
||||
\ '~/dev/carepal/carepal-templates',
|
||||
\ '~/dev/eaccounting/eaccounting-app',
|
||||
\ '~/dev/eaccounting/eaccounting-server',
|
||||
\ '~/dev/eaccounting/eaccounting-validator',
|
||||
\ '/etc/nixos',
|
||||
\ ]
|
||||
|
||||
let mapleader=" "
|
||||
let g:camelcasemotion_key = '<leader>'
|
||||
|
||||
let g:lightline = {
|
||||
\ 'colorscheme': 'powerline',
|
||||
\ 'active': {
|
||||
\ 'left': [ [ 'mode', 'paste' ],
|
||||
\ [ 'cocstatus', 'currentfunction', 'readonly', 'filename', 'modified' ] ]
|
||||
\ },
|
||||
\ 'component_function': {
|
||||
\ 'cocstatus': 'coc#status',
|
||||
\ 'currentfunction': 'CocCurrentFunction'
|
||||
\ },
|
||||
\ }
|
||||
|
||||
" omnisharp-vim config:
|
||||
let g:OmniSharp_server_stdio = 1
|
||||
let g:OmniSharp_server_path = '/home/felschr/.nix-profile/bin/omnisharp'
|
||||
let g:OmniSharp_selector_ui = 'fzf'
|
||||
let g:OmniSharp_highlight_types = 3
|
||||
let g:OmniSharp_typeLookupInPreview = 1
|
||||
let g:ale_linters_explicit = 1
|
||||
let g:ale_linters = {
|
||||
\ 'cs': ['OmniSharp']
|
||||
\ }
|
||||
|
||||
" nvim-lsp using neovim's official LSP interface
|
||||
" call nvim_lsp#setup("tsserver", {})
|
||||
" call nvim_lsp#setup("ghcide", {})
|
||||
|
||||
set relativenumber
|
||||
set splitbelow
|
||||
|
||||
map ; :Files<CR>
|
||||
nmap <C-l> :NERDTreeToggle<CR>
|
||||
map <Leader> <Plug>(easymotion-prefix)
|
||||
|
||||
" Terminal Function
|
||||
let g:term_buf = 0
|
||||
let g:term_win = 0
|
||||
function! TermToggle(height)
|
||||
if win_gotoid(g:term_win)
|
||||
hide
|
||||
else
|
||||
botright new
|
||||
exec "resize " . a:height
|
||||
try
|
||||
exec "buffer " . g:term_buf
|
||||
catch
|
||||
call termopen($SHELL, {"detach": 0})
|
||||
let g:term_buf = bufnr("")
|
||||
set nonumber
|
||||
set norelativenumber
|
||||
set signcolumn=no
|
||||
endtry
|
||||
startinsert!
|
||||
let g:term_win = win_getid()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Toggle terminal on/off (neovim)
|
||||
nnoremap <A-t> :call TermToggle(12)<CR>
|
||||
inoremap <A-t> <Esc>:call TermToggle(12)<CR>
|
||||
tnoremap <A-t> <C-\><C-n>:call TermToggle(12)<CR>
|
||||
|
||||
" Terminal go back to normal mode
|
||||
tnoremap :q! <C-\><C-n>:q!<CR>
|
113
home/editors/neovim.nix
Normal file
113
home/editors/neovim.nix
Normal file
|
@ -0,0 +1,113 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
buildVimPluginFrom2Nix = pkgs.vimUtils.buildVimPluginFrom2Nix;
|
||||
|
||||
omnisharp-vim = buildVimPluginFrom2Nix {
|
||||
pname = "omnisharp-vim";
|
||||
version = "master";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "FelschR";
|
||||
repo = "omnisharp-vim";
|
||||
rev = "3eb38ffbf6295d24e544b72fb349e876cd28ad96";
|
||||
sha256 = "0wvhjv7rdscm0kps72wlbyhqk99j6c6flqsd2vkj0v985l48nzhz";
|
||||
};
|
||||
};
|
||||
nvim-lsp = buildVimPluginFrom2Nix {
|
||||
pname = "nvim-lsp";
|
||||
version = "master";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "neovim";
|
||||
repo = "nvim-lsp";
|
||||
rev = "7a15a52c0a7d735625ac73dc4d8efe70c5e99707";
|
||||
sha256 = "1wpp54gvb90qhgnxmp3fvfc3dbkdxk3q712c7wyd9alpbk4608fk";
|
||||
};
|
||||
};
|
||||
# coc-omnisharp = buildVimPluginFrom2Nix {
|
||||
# pname = "coc-omnisharp";
|
||||
# version = "master";
|
||||
# src = pkgs.fetchFromGitHub {
|
||||
# owner = "coc-extensions";
|
||||
# repo = "coc-omnisharp";
|
||||
# rev = "9c062bbae5692b69b5cf918131a972405b2582b9";
|
||||
# sha256 = "1phjnzgh8918cb915jn92i5vv23lki95q9x0nsjddna3gz3c9k0w";
|
||||
# };
|
||||
# };
|
||||
in
|
||||
{
|
||||
nixpkgs.overlays = [
|
||||
(self: super: {
|
||||
neovim-unwrapped = super.neovim-unwrapped.overrideAttrs (oldAttrs: rec {
|
||||
version = "master-lsp";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "neovim";
|
||||
repo = "neovim";
|
||||
rev = "f1923d4b92239ef2ca280bf1ce6c5f6cc7cb4f1a";
|
||||
sha256 = "1algrgwvv38sw0spxraff3s0fqnb6pz7xd66cf6dd2vnsvnhpay5";
|
||||
};
|
||||
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [
|
||||
pkgs.utf8proc
|
||||
];
|
||||
});
|
||||
})
|
||||
];
|
||||
|
||||
home.packages = with pkgs; [
|
||||
nodejs-12_x
|
||||
# haskellPackages.ghcide
|
||||
];
|
||||
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
gruvbox
|
||||
editorconfig-vim
|
||||
fzf-vim
|
||||
lightline-vim
|
||||
nerdtree
|
||||
vim-startify
|
||||
vim-polyglot
|
||||
vim-multiple-cursors
|
||||
vim-surround
|
||||
vim-commentary
|
||||
vim-easymotion
|
||||
vim-peekaboo
|
||||
vim-gitgutter
|
||||
vim-fugitive
|
||||
vim-test
|
||||
camelcasemotion
|
||||
argtextobj-vim
|
||||
|
||||
# nvim-lsp # nixos-rebuild currently fails
|
||||
|
||||
vim-orgmode
|
||||
vim-nix
|
||||
|
||||
# Most coc-* plugins are incomplete in nixpkgs
|
||||
# Instead they are currently installed manually via :CocInstall
|
||||
coc-nvim
|
||||
# coc-tabnine
|
||||
# coc-pairs
|
||||
# coc-emmet
|
||||
# coc-snippets
|
||||
# coc-highlight
|
||||
# coc-html
|
||||
# coc-css
|
||||
# coc-tsserver
|
||||
# coc-json
|
||||
# coc-yaml
|
||||
# coc-eslint
|
||||
# coc-stylelint
|
||||
# coc-prettier
|
||||
# coc-angular
|
||||
# # coc-omnisharp # not really maintained
|
||||
|
||||
ale # only used for omnisharp-vim
|
||||
omnisharp-vim
|
||||
];
|
||||
extraConfig = with builtins; readFile ./init.vim + readFile ./coc.vim;
|
||||
withNodeJs = true;
|
||||
};
|
||||
}
|
7
home/editors/vscode.nix
Normal file
7
home/editors/vscode.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
# programs.vscode.enable = true;
|
||||
|
||||
home.packages = [ pkgs.vscode ];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue