Setup coc+ghcide
This commit is contained in:
parent
f51d9629db
commit
cdb627ede8
|
@ -1,3 +1,4 @@
|
|||
|
||||
# WARN: this file will get overwritten by $ cachix use <name>
|
||||
{ pkgs, lib, ... }:
|
||||
|
||||
|
@ -5,9 +6,9 @@ let
|
|||
folder = ./cachix;
|
||||
toImport = name: value: folder + ("/" + name);
|
||||
filterCaches = key: value: value == "regular" && lib.hasSuffix ".nix" key;
|
||||
imports = lib.mapAttrsToList toImport
|
||||
(lib.filterAttrs filterCaches (builtins.readDir folder));
|
||||
imports = lib.mapAttrsToList toImport (lib.filterAttrs filterCaches (builtins.readDir folder));
|
||||
in {
|
||||
inherit imports;
|
||||
nix.binaryCaches = [ "https://cache.nixos.org/" ];
|
||||
nix.binaryCaches = ["https://cache.nixos.org/"];
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
nix = {
|
||||
binaryCaches = [ "https://all-hies.cachix.org" ];
|
||||
binaryCachePublicKeys =
|
||||
[ "all-hies.cachix.org-1:JjrzAOEUsD9ZMt8fdFbzo3jNAyEWlPAwdVuHw4RD43k=" ];
|
||||
trustedUsers = [ "root" "maralorn" ];
|
||||
};
|
||||
}
|
12
cachix/hercules-ci.nix
Normal file
12
cachix/hercules-ci.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
|
||||
{
|
||||
nix = {
|
||||
binaryCaches = [
|
||||
"https://hercules-ci.cachix.org"
|
||||
];
|
||||
binaryCachePublicKeys = [
|
||||
"hercules-ci.cachix.org-1:ZZeDl9Va+xe9j+KqdzoBZMFJHVQ42Uu/c/1/KMC5Lw0="
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
@ -147,39 +147,56 @@ in {
|
|||
home = {
|
||||
packages = builtins.attrValues my-pkgs.home-pkgs;
|
||||
sessionVariables = {
|
||||
GITSTATUS_DAEMON = "${my-pkgs.gitstatus}/bin/gitstatusd";
|
||||
PATH =
|
||||
"$HOME/.cargo/bin:/etc/profiles/per-user/${config.home.username}/bin:$HOME/.nix-profile/bin:$PATH";
|
||||
BROWSER = "${pkgs.firefox}/bin/firefox";
|
||||
EDITOR = "${pkgs.neovim}/bin/nvim";
|
||||
TERMINAL = config.m-0.terminal;
|
||||
EMAIL = me.mail;
|
||||
SUDO_ASKPASS = let
|
||||
print-pw = pkgs.writeShellScriptBin "print-pw"
|
||||
BROWSER = "${pkgs.firefox}/bin/firefox";
|
||||
EDITOR = "${pkgs.neovim}/bin/nvim";
|
||||
TERMINAL = config.m-0.terminal;
|
||||
EMAIL = me.mail;
|
||||
SUDO_ASKPASS = let
|
||||
print-pw = pkgs.writeShellScriptBin "print-pw"
|
||||
"pass show eu/m-0/${config.m-0.hostName}/user/${config.home.username}";
|
||||
in "${print-pw}/bin/print-pw";
|
||||
in "${print-pw}/bin/print-pw";
|
||||
};
|
||||
file.".config/nvim/coc-settings.json".text = builtins.toJSON {
|
||||
languageserver = {
|
||||
haskell = {
|
||||
command = "ghcide";
|
||||
args = [ "--lsp" ];
|
||||
rootPatterns = [
|
||||
".stack.yaml"
|
||||
".hie-bios"
|
||||
"BUILD.bazel"
|
||||
"cabal.config"
|
||||
"package.yaml"
|
||||
];
|
||||
filetypes = [ "hs" "lhs" "haskell" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
fonts.fontconfig.enableProfileFonts = true;
|
||||
};
|
||||
fonts.fontconfig.enableProfileFonts = true;
|
||||
|
||||
systemd.user = {
|
||||
startServices = true;
|
||||
services.lorri-daemon = {
|
||||
Unit = { Description = "Run lorri daemon"; };
|
||||
Service = {
|
||||
Environment =
|
||||
"RUST_BACKTRACE=1 PATH=${pkgs.nix}/bin:${pkgs.coreutils}/bin";
|
||||
ExecStart = "${lorri}/bin/lorri daemon";
|
||||
};
|
||||
};
|
||||
systemd.user = {
|
||||
startServices = true;
|
||||
services.lorri-daemon = {
|
||||
Unit = { Description = "Run lorri daemon"; };
|
||||
Service = {
|
||||
Environment =
|
||||
"RUST_BACKTRACE=1 PATH=${pkgs.nix}/bin:${pkgs.coreutils}/bin";
|
||||
ExecStart = "${lorri}/bin/lorri daemon";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
gpg-agent = {
|
||||
enable = true;
|
||||
defaultCacheTtl = 31536000; # 1year
|
||||
maxCacheTtl = 31536000; # 1year
|
||||
};
|
||||
};
|
||||
services = {
|
||||
gpg-agent = {
|
||||
enable = true;
|
||||
defaultCacheTtl = 31536000; # 1year
|
||||
maxCacheTtl = 31536000; # 1year
|
||||
};
|
||||
};
|
||||
|
||||
xdg.enable = true;
|
||||
}
|
||||
xdg.enable = true;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ rec {
|
|||
});
|
||||
shh = unBreak unstable.haskellPackages.shh;
|
||||
ghc = unstable.ghc.withPackages
|
||||
(p: [ (unBreak p.shh) p.brittany p.hlint p.ghcid ]);
|
||||
(p: [ (unBreak p.shh) p.brittany p.hlint p.ghcid p.cabal-install ]);
|
||||
haskellList = list: ''["${builtins.concatStringsSep ''", "'' list}"]'';
|
||||
writeHaskellScript = { name ? "haskell-script", bins ? [ pkgs.coreutils ]
|
||||
, libraries ? [ ], imports ? [ ] }:
|
||||
|
|
|
@ -11,6 +11,18 @@
|
|||
"url": "https://github.com/cachix/cachix/archive/5c7272351c4e87adabfb8a31e5b9c1db2980abf3.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"ghcide": {
|
||||
"branch": "master",
|
||||
"description": "Nix installation for ghcide",
|
||||
"homepage": "https://github.com/digital-asset/ghcide",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "ghcide-nix",
|
||||
"rev": "6780371c68756cb103ae5b513b2d9f244581b03b",
|
||||
"sha256": "05jamp6hajkymvqs1s6ydy0x6dy84qykv27j5y6pyzyrfry2ih9s",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/hercules-ci/ghcide-nix/archive/6780371c68756cb103ae5b513b2d9f244581b03b.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"home-manager": {
|
||||
"branch": "release-19.03",
|
||||
"description": "Manage a user environment using Nix",
|
||||
|
|
|
@ -2,8 +2,21 @@ let
|
|||
my-lib = import ../lib;
|
||||
inherit (my-lib) pkgs unstable sources writeHaskellScript gcRetentionDays;
|
||||
in rec {
|
||||
gitstatus = pkgs.callPackage ./powerlevel10k/gitstatus.nix {
|
||||
libgit2 = pkgs.libgit2.overrideAttrs (attrs: {
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "romkatv";
|
||||
repo = "libgit2";
|
||||
rev = "a546b232b23814de9c561fc750791363a5ed347e";
|
||||
sha256 = "1xx782qa36f5gfjflw64r383g5gh7wgkvxk5q4w0rg8c0xwa3hk6";
|
||||
};
|
||||
});
|
||||
};
|
||||
zsh-powerlevel10k =
|
||||
pkgs.callPackage ./powerlevel10k/zsh-powerlevel10k.nix { };
|
||||
ghcide = (import sources.ghcide { }).ghcide-ghc865;
|
||||
tasktree = pkgs.callPackage ./tasktree { };
|
||||
neovim = pkgs.neovim.override {
|
||||
neovim = unstable.neovim.override {
|
||||
vimAlias = true;
|
||||
withPython3 = true;
|
||||
};
|
||||
|
@ -11,7 +24,7 @@ in rec {
|
|||
src = sources.lorri;
|
||||
pkgs = unstable;
|
||||
};
|
||||
home-neovim = (import ./nvim) neovim;
|
||||
home-neovim = (import ./nvim) unstable.neovim;
|
||||
niv = (import sources.niv { }).niv;
|
||||
|
||||
# pkgs assumed to be present on a non nixos host
|
||||
|
@ -153,9 +166,9 @@ in rec {
|
|||
home-pkgs = {
|
||||
nixfmt = import sources.nixfmt { };
|
||||
inherit (pkgs.pythonPackages) yapf jsbeautifier;
|
||||
inherit (pkgs) ncmpcpp shfmt htmlTidy astyle;
|
||||
inherit (pkgs) ncmpcpp shfmt htmlTidy astyle nodejs;
|
||||
inherit (my-lib) ghc;
|
||||
inherit home-neovim;
|
||||
inherit home-neovim ghcide;
|
||||
};
|
||||
accounting-pkgs = {
|
||||
jali = pkgs.callPackage ./jali { };
|
||||
|
|
|
@ -8,7 +8,11 @@ n.override {
|
|||
start = builtins.attrValues {
|
||||
inherit ((import <nixpkgs> { }).vimPlugins)
|
||||
vim-nix vimtex airline rust-vim fugitive vim-trailing-whitespace
|
||||
vim-pandoc vim-pandoc-syntax haskell-vim vim-autoformat vim-ledger;
|
||||
vim-airline-themes vim-pandoc vim-pandoc-syntax haskell-vim
|
||||
vim-autoformat vim-ledger;
|
||||
inherit ((import <unstable> { }).vimPlugins)
|
||||
coc-nvim coc-python coc-rls coc-yaml coc-vimtex coc-css coc-json
|
||||
coc-html coc-git;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
129
pkgs/nvim/vimrc
129
pkgs/nvim/vimrc
|
@ -51,3 +51,132 @@ let g:formatters_nix = ['my_nix']
|
|||
au BufWrite * :Autoformat
|
||||
let g:autoformat_autoindent = 0
|
||||
let g:autoformat_retab = 0
|
||||
|
||||
" 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
|
||||
|
||||
" 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.
|
||||
" Coc only does snippet and additional edit on confirm.
|
||||
inoremap <expr> <cr> pumvisible() ? "\<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 <tab> for select selections ranges, needs server support, like: coc-tsserver, coc-python
|
||||
nmap <silent> <TAB> <Plug>(coc-range-select)
|
||||
xmap <silent> <TAB> <Plug>(coc-range-select)
|
||||
xmap <silent> <S-TAB> <Plug>(coc-range-select-backword)
|
||||
|
||||
" 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')
|
||||
|
||||
" Add status line support, for integration with other plugin, checkout `:h coc-status`
|
||||
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
|
||||
|
||||
" 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>
|
||||
|
|
Loading…
Reference in a new issue