225 lines
5.1 KiB
Nix
225 lines
5.1 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.programs.custom.vim;
|
|
|
|
nix-xptemplates = pkgs.writeTextFile {
|
|
name = "nix-xptemplates";
|
|
destination = "/ftplugin/nix/nix.xpt.vim";
|
|
text = # vim
|
|
''
|
|
XPTemplate priority=personal
|
|
|
|
XPT option " tips
|
|
`name^ = mkOption {
|
|
type = with types; `type^;
|
|
description = ${"''"}
|
|
`cursor^
|
|
${"''"};
|
|
};
|
|
|
|
XPT package " tips
|
|
{ config, lib, ... }:
|
|
{
|
|
`cursor^
|
|
}
|
|
|
|
XPT terranix" tips
|
|
{ config, lib, pkgs, ... }:
|
|
with lib;
|
|
let
|
|
cfg = config.`name^;
|
|
in {
|
|
|
|
options.`name^ = mkOption {
|
|
default = {};
|
|
type = with types; attrsOf (submodule ({ name, ... }:{
|
|
options = {
|
|
enable = mkEnableOption "`name^.name";
|
|
};
|
|
}));
|
|
};
|
|
|
|
config =
|
|
let
|
|
allConfigs = cfg
|
|
in
|
|
mkIf (cfg != {} ){
|
|
`cursor^
|
|
};
|
|
}
|
|
|
|
XPT module " tips
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.`name^;
|
|
|
|
in {
|
|
|
|
options.`name^ = {
|
|
enable = mkEnableOption "enable `name^";
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
`cursor^
|
|
};
|
|
}
|
|
|
|
XPT shell " tips
|
|
{ pkgs ? import <nixpkgs> {} }:
|
|
pkgs.mkShell {
|
|
|
|
# needed pkgs
|
|
# -----------
|
|
buildInputs = with pkgs; [
|
|
`name^
|
|
];
|
|
|
|
# run this on start
|
|
# -----------------
|
|
shellHook = ${"''"}
|
|
HISTFILE=${"$"}{toString ./.}/.history
|
|
${"''"};
|
|
}
|
|
|
|
XPT fhsUser " tips
|
|
{ pkgs ? import <nixpkgs> {} }:
|
|
(pkgs.buildFHSUserEnv {
|
|
name = "fhs-user-env";
|
|
|
|
targetPkgs = pkgs: with pkgs; [
|
|
# core stuff
|
|
# ----------
|
|
vim silver-searcher curl coreutils git tig
|
|
|
|
# common X dependencies
|
|
# ---------------------
|
|
atk cairo dbus eudev expat fontconfig freetype gdk_pixbuf glib gnome3.GConf gtk2-x11
|
|
mesa_glu nspr nss pango xlibs.libXScrnSaver xlibs.libXcomposite xlibs.libXcursor
|
|
xlibs.libXdamage xlibs.libXfixes xlibs.libXi xlibs.libXrender xlibs.libXtst xorg.libX11
|
|
xorg.libXext xorg.libXinerama xorg.libxcb
|
|
liblo zlib fftw minixml libcxx alsaLib glibc
|
|
|
|
# new stuff
|
|
# ---------
|
|
`cursor^
|
|
|
|
];
|
|
|
|
# multilib packages
|
|
# -----------------
|
|
# these are packages compiled 32bit and 64bit
|
|
multiPkgs = pkgs: with pkgs; [
|
|
];
|
|
|
|
# environment variables
|
|
# ---------------------
|
|
profile = ${"''"}
|
|
export TERM="xterm"
|
|
${"''"};
|
|
|
|
}).env
|
|
|
|
'';
|
|
};
|
|
|
|
# active plugins
|
|
# --------------
|
|
extra-runtimepath = with pkgs;
|
|
lib.concatMapStringsSep "," (pkg: "${pkg.rtp}") [
|
|
vimPlugins.Syntastic
|
|
vimPlugins.ack-vim
|
|
vimPlugins.airline
|
|
vimPlugins.vim-nix
|
|
vimPlugins.xptemplate
|
|
];
|
|
|
|
# the vimrc
|
|
# ---------
|
|
vimrc = pkgs.writeText "vimrc" ''
|
|
|
|
" turn on linenumbers
|
|
" to turn of :set nonumber
|
|
:set number
|
|
|
|
" show Trailing Whitespaces
|
|
:set list listchars=tab:»·,trail:¶
|
|
|
|
" Map leader is the key for shortcuts
|
|
nnoremap <SPACE> <Nop>
|
|
let mapleader = "\<Space>"
|
|
|
|
" move blocks of text in visual mode
|
|
" does not work correctly
|
|
vmap <up> xkP`[V`]
|
|
vmap <down> xp`[V`]
|
|
|
|
" search/grep case insensitive
|
|
:set ignorecase
|
|
|
|
" tabs should always be 2 spaces
|
|
set et ts=2 sts=2 sw=2
|
|
|
|
" installed vim-plugins
|
|
set runtimepath=${extra-runtimepath},$VIMRUNTIME,$HOME/.vim,${nix-xptemplates}
|
|
|
|
" syntax highlighting on
|
|
syntax on
|
|
|
|
" xptemplates
|
|
" -----------
|
|
" a plugin to insert snippets on demand
|
|
set nocompatible
|
|
filetype plugin on
|
|
|
|
" enable cursor cross
|
|
" -------------------
|
|
":hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
|
|
":hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
|
|
:hi CursorLine cterm=NONE ctermbg=0 guibg=#073642
|
|
:hi CursorColumn cterm=NONE ctermbg=0 guibg=#073642
|
|
set cursorline
|
|
set cursorcolumn
|
|
|
|
" save view
|
|
" ---------
|
|
augroup AutoSaveFolds
|
|
autocmd!
|
|
autocmd BufWinLeave * mkview
|
|
autocmd BufWinEnter * silent loadview
|
|
augroup END
|
|
|
|
" some language stuff
|
|
" -------------------
|
|
:map <leader>s :setlocal spell spelllang=en
|
|
|
|
'';
|
|
|
|
in
|
|
{
|
|
|
|
# no options
|
|
options.programs.custom.vim.enable = lib.mkEnableOption "vim";
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
# create vimrc
|
|
# ------------
|
|
# and load it as config for vim
|
|
environment.variables.VIMINIT = ":so /etc/vimrc";
|
|
environment.etc.vimrc.source = vimrc;
|
|
|
|
# set vim to the default editor
|
|
# -----------------------------
|
|
programs.vim.defaultEditor = true;
|
|
|
|
# install vim
|
|
# -----------
|
|
environment.systemPackages = [ pkgs.vim ];
|
|
};
|
|
|
|
}
|