From 5c8a2a8504519d43b5b681424b3694dca0418965 Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Tue, 24 Jan 2023 22:37:01 +0100 Subject: Use a basic vim instead of Emacs on servers --- .gitmodules | 3 +++ tw/home/files/vimrc | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ tw/home/files/zshrc | 7 +++--- tw/home/server.scm | 21 ++++++++++++++---- tw/theme.scm | 4 ++++ tw/theme/catppuccin/vim | 1 + 6 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 tw/home/files/vimrc create mode 160000 tw/theme/catppuccin/vim diff --git a/.gitmodules b/.gitmodules index c3ec2737..cd1f5f83 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,3 +28,6 @@ [submodule "neomutt"] path = tw/home/files/neomutt url = https://github.com/neomutt/neomutt +[submodule "tw/theme/catppuccin/vim"] + path = tw/theme/catppuccin/vim + url = https://github.com/catppuccin/vim diff --git a/tw/home/files/vimrc b/tw/home/files/vimrc new file mode 100644 index 00000000..ec908792 --- /dev/null +++ b/tw/home/files/vimrc @@ -0,0 +1,57 @@ +let mapleader = "\" +let maplocalleader = "\\" + +set showcmd " show command as they are typed +set showmatch " show matching brackets, briefly jump to matching one +set matchtime=0 " tenths of a sec to jump to matching brackets +set showmode " show NORMAL/INSERT/VISUAL indicator +set ruler " show cursor position +set number " show line numbers +set cursorline " highlight current line +set modeline " check for modelines +set hlsearch " highlight search results +set ignorecase " case-insensitive searching +set smartcase " ...unless query has capital letters +set incsearch " incremental search +set gdefault " :s/search/replace/ has g by default +set magic " use extended regexes +set wildmenu " autocomplete :commands +set nolazyredraw " redraw during macro execution etc. +set foldlevelstart=10 " open most folds by default +set foldmethod=syntax " (or marker, manual, expr, syntax, diff) +set noequalalways " don't resize all windows when closing/opening another +set eadirection=both " 'equalalways' applies horizontally and vertically + +set expandtab " tabs are actually spaces +set tabstop=4 " tab width +set softtabstop=4 " when reading a '\t', it will be this wide +set shiftwidth=4 " autoindent tab width +set list " show whitespace with characters in 'listchars' +" possible chars: eol, tab, space, trail, extends, precedes, conceal, nbsp +set listchars=tab:>\ ,trail:_ " highlight tabs and trailing spaces specially +set showbreak=>\ " character to show at start of wrapped lines +set nojoinspaces " don't add two spaces after [.!?] + +set scrolloff=5 " always show these many lines around the current one +set sidescrolloff=15 " always show these many columns around the current one +set colorcolumn=80 " highlight 80th column +set textwidth=79 " break long lines on whitespace when inserted +set linebreak " wrap by words (affects display only) +set breakindent " wrapped lines have same virtual indent as first line +set formatoptions=tcqn2 " preserve textwidth, comments, allow gq, numbered + " lists, second line indent + +set mouse=a " use mouse in terminal; press shift to disable temporarily +set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50 + \,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor + \,sm:block-blinkwait175-blinkoff150-blinkon175 + +" Fix colours in kitty -- see :help xterm-true-color. +set termguicolors +let &t_8f = "\[38;2;%lu;%lu;%lum" +let &t_8b = "\[48;2;%lu;%lu;%lum" + +filetype on +syntax on + +source ~/.vim/catppuccin.vim diff --git a/tw/home/files/zshrc b/tw/home/files/zshrc index a13df739..5d26d9d3 100644 --- a/tw/home/files/zshrc +++ b/tw/home/files/zshrc @@ -84,9 +84,10 @@ fi ## Aliases alias e="${VISUAL-$EDITOR}" -# Use ASYNC_EDITOR so I can continue using the shell while the editor -# remains open in a separate window. -alias em="$ASYNC_EDITOR" +# Use ASYNC_EDITOR so I can continue using the shell while the editor remains +# open in a separate window. If no ASYNC_EDITOR is defined (e.g. on servers), +# then use the regular editor for convenience. +alias em="${ASYNC_EDITOR-${VISUAL-$EDITOR}}" alias se='sudo -e' alias ls='\ls --color=auto -h' alias la='\ls --color=auto -hA' diff --git a/tw/home/server.scm b/tw/home/server.scm index cc80c3c3..2cc0ceaf 100644 --- a/tw/home/server.scm +++ b/tw/home/server.scm @@ -1,11 +1,24 @@ (define-module (tw home server) + #:use-module (gnu) #:use-module (gnu home) + #:use-module (gnu home services) #:use-module (tw home) - #:use-module (tw home emacs)) + #:use-module (tw theme)) + +(use-package-modules vim) (home-environment ;; These packages will show up in the home profile, under ~/.guix-home/profile. - (packages (append common-packages emacs-packages)) + (packages + (cons* vim vim-surround common-packages)) ;; To search for available home services, run 'guix home search KEYWORD'. - (services (append (gnupg-services #:gui-pinentry? #f) - common-services emacs-services))) + (services + (cons* + (simple-service 'vim-config home-files-service-type + `((".vim/vimrc" ,(local-file "files/vimrc")) + (".vim/catppuccin.vim" ,catppuccin-vim))) + + (simple-service 'vim-is-editor home-environment-variables-service-type + `(("EDITOR" . "vim"))) ; we define no ASYNC_EDITOR + + (append common-services (gnupg-services #:gui-pinentry? #f))))) diff --git a/tw/theme.scm b/tw/theme.scm index a7ee78a5..47a60bb8 100644 --- a/tw/theme.scm +++ b/tw/theme.scm @@ -83,6 +83,10 @@ (("JetBrainsMono Nerd Font 14") "Fira Sans 12") ; default font (("border-col: #[0-9a-f]*;") "border-col: #585b70;")))))) ; i3 border colour +(define-public catppuccin-vim + (local-file #.(string-append "theme/catppuccin/vim/colors/catppuccin_" + catppuccin-theme-variant ".vim"))) + (define-public catppuccin-zathura (local-file #.(string-append "theme/catppuccin/zathura/src/catppuccin-" catppuccin-theme-variant))) diff --git a/tw/theme/catppuccin/vim b/tw/theme/catppuccin/vim new file mode 160000 index 00000000..cf186cff --- /dev/null +++ b/tw/theme/catppuccin/vim @@ -0,0 +1 @@ +Subproject commit cf186cffa9b3b896b03e94247ac4b56994a09e34 -- cgit v1.2.3