l vim: update

This commit is contained in:
lassulus 2023-09-03 12:33:23 +02:00
parent c15ec193d6
commit f0af62110f

View File

@ -1,15 +1,15 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with import <stockholm/lib>;
let let
out = { out = {
environment.systemPackages = [ environment.systemPackages = [
(hiPrio vim) (lib.hiPrio vim)
]; ];
environment.etc.vimrc.source = vimrc; environment.etc.vimrc.source = vimrc;
environment.etc.vim.source = vim;
environment.variables.EDITOR = mkForce "vim"; environment.variables.EDITOR = lib.mkForce "vim";
environment.variables.VIMINIT = ":so /etc/vimrc"; environment.variables.VIMINIT = ":so /etc/vimrc";
}; };
@ -43,6 +43,9 @@ let
set wildmenu set wildmenu
set wildmode=longest,full set wildmode=longest,full
" enable better-whitespace
let g:better_whitespace_enabled=1
set title set title
set titleold= set titleold=
set titlestring=(vim)\ %t%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)\ -\ %{v:servername} set titlestring=(vim)\ %t%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)\ -\ %{v:servername}
@ -122,10 +125,12 @@ let
let g:fzf_layout = { 'down': '~15%' } let g:fzf_layout = { 'down': '~15%' }
''; '';
extra-runtimepath = concatMapStringsSep "," (pkg: "${pkg.rtp}") [ extra-runtimepath = lib.concatMapStringsSep "," (pkg: "${pkg.rtp}") [
pkgs.vimPlugins.copilot-vim
pkgs.vimPlugins.undotree pkgs.vimPlugins.undotree
pkgs.vimPlugins.fzf-vim pkgs.vimPlugins.fzf-vim
pkgs.vimPlugins.fzfWrapper pkgs.vimPlugins.fzfWrapper
pkgs.vimPlugins.vim-better-whitespace
(pkgs.vimUtils.buildVimPlugin { (pkgs.vimUtils.buildVimPlugin {
name = "file-line-1.0"; name = "file-line-1.0";
src = pkgs.fetchFromGitHub { src = pkgs.fetchFromGitHub {
@ -144,19 +149,6 @@ let
sha256 = "sha256-lyTZUgqUEEJRrzGo1FD8/t8KBioPrtB3MmGvPeEVI/g="; sha256 = "sha256-lyTZUgqUEEJRrzGo1FD8/t8KBioPrtB3MmGvPeEVI/g=";
}; };
}) })
((rtp: rtp // { inherit rtp; }) (pkgs.writeTextFile (let
name = "vim";
in {
name = "vim-syntax-${name}-1.0.0";
destination = "/syntax/${name}.vim";
text = /* vim */ ''
${concatMapStringsSep "\n" (s: /* vim */ ''
syn keyword vimColor${s} ${s}
\ containedin=ALLBUT,vimComment,vimLineComment
hi vimColor${s} ctermfg=${s}
'') (map (i: lpad 3 "0" (toString i)) (range 0 255))}
'';
})))
((rtp: rtp // { inherit rtp; }) (pkgs.writeTextFile (let ((rtp: rtp // { inherit rtp; }) (pkgs.writeTextFile (let
name = "showsyntax"; name = "showsyntax";
in { in {
@ -193,16 +185,19 @@ let
}; };
mkdirs = let mkdirs = let
dirOf = s: let out = concatStringsSep "/" (init (splitString "/" s)); dirOf = s: let out = lib.concatStringsSep "/" (lib.init (lib.splitString "/" s));
in assert out != ""; out; in assert out != ""; out;
alldirs = attrValues dirs ++ map dirOf (attrValues files); alldirs = lib.attrValues dirs ++ map dirOf (lib.attrValues files);
in unique (sort lessThan alldirs); in lib.unique (lib.sort lib.lessThan alldirs);
vim = pkgs.symlinkJoin { vim = pkgs.symlinkJoin {
name = "vim"; name = "vim";
paths = [ paths = [
(pkgs.writeDashBin "vim" '' (pkgs.writers.writeDashBin "vim" ''
set -efu set -efu
export PATH=$PATH:${lib.makeBinPath [
pkgs.nodejs
]}
(umask 0077; exec ${pkgs.coreutils}/bin/mkdir -p ${toString mkdirs}) (umask 0077; exec ${pkgs.coreutils}/bin/mkdir -p ${toString mkdirs})
exec ${pkgs.vim}/bin/vim "$@" exec ${pkgs.vim}/bin/vim "$@"
'') '')
@ -267,18 +262,18 @@ let
syn cluster nix_ind_strings contains=NixIND_STRING syn cluster nix_ind_strings contains=NixIND_STRING
syn cluster nix_strings contains=NixSTRING syn cluster nix_strings contains=NixSTRING
${concatStringsSep "\n" (mapAttrsToList (lang: { extraStart ? null }: let ${lib.concatStringsSep "\n" (lib.mapAttrsToList (lang: { extraStart ? null }: let
startAlts = filter isString [ startAlts = lib.filter lib.isString [
''/\* ${lang} \*/'' ''/\* ${lang} \*/''
extraStart extraStart
]; ];
sigil = ''\(${concatStringsSep ''\|'' startAlts}\)[ \t\r\n]*''; sigil = ''\(${lib.concatStringsSep ''\|'' startAlts}\)[ \t\r\n]*'';
in /* vim */ '' in /* vim */ ''
syn include @nix_${lang}_syntax syntax/${lang}.vim syn include @nix_${lang}_syntax syntax/${lang}.vim
unlet b:current_syntax unlet b:current_syntax
syn match nix_${lang}_sigil syn match nix_${lang}_sigil
\ X${replaceStrings ["X"] ["\\X"] sigil}\ze\('''\|"\)X \ X${lib.replaceStrings ["X"] ["\\X"] sigil}\ze\('''\|"\)X
\ nextgroup=nix_${lang}_region_IND_STRING,nix_${lang}_region_STRING \ nextgroup=nix_${lang}_region_IND_STRING,nix_${lang}_region_STRING
\ transparent \ transparent