Skip to content

Instantly share code, notes, and snippets.

@emilcarr
Last active June 5, 2024 20:59
Show Gist options
  • Save emilcarr/3e3fa4a0fde0d2d86a4e338366878eab to your computer and use it in GitHub Desktop.
Save emilcarr/3e3fa4a0fde0d2d86a4e338366878eab to your computer and use it in GitHub Desktop.
urxvt and vim setup for productivity

urxvt and nvim Setup for Productivity

Install nvim, urxvt and zsh:

Arch:

# pacman -S neovim rxvt-unicode zsh wl-clipboard

Debian:

# sudo apt install neovim rxvt-unicode zsh

Change default shell to zsh:

$ chsh -s $(which zsh)

Install ohmyzsh:

$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Set theme in ~/.zshrc:

# Edit this line
ZSH_THEME="agnoster"

# Add these lines
bindkey "${terminfo[khome]}" beginning-of-line
bindkey "${terminfo[kend]}" end-of-line

Install Inconsolata for Powerline and Inconsolata NF:

$ wget https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.0/Inconsolata.zip
$ unzip Inconsolata.zip
# cp *.ttf /usr/share/fonts/TTF
$ wget https://github.com/powerline/fonts/blob/master/Inconsolata/Inconsolata%20for%20Powerline.otf
# cp *.otf /usr/share/fonts/OTF
$ fc-cache -fv

Follow these instructions on Arch Wiki to fix home and end keys: https://wiki.archlinux.org/title/Home_and_End_keys_not_working#Terminfo

Download ~/.Xresources and merge:

$ xrdb -merge ~/.Xresources

Install vim-plug:

$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Download ~/.vimrc

Save default coc.nvim from https://github.com/neoclide/coc.nvim to ~/.vim/coc.vim

Download ~/.vim/colors/custom.vim

Open nvim and run :PlugInstall then restart

Open :CocConfig and paste in the contents of coc-settings.json

Launch nvim and be productive.

" Load vim default settings
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" setup indentation
filetype plugin indent on
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
syntax on " enable syntax highlighting
set ignorecase
set smartcase
let mapleader=","
set number
" show file titles
set title
set statusline=\ %f
set nowrap
set clipboard+=unnamedplus
" y u no werk (home and end key setup)
map <ESC>[1~ <Home>
map <ESC>[4~ <End>
imap <ESC>[1~ <Home>
imap <ESC>[4~ <End>
" Map forward/back keys on mouse
map <X1Mouse> <C-O>
map <X2Mouse> <C-I>
" TODO above maps to TAB
" Plugin configuration
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'preservim/nerdtree'
Plug 'numirias/semshi', { 'do': ':UpdateRemotePlugins'} " Python syntax highlighting
Plug 'tclem/vim-arduino' " Arduino syntax highlighting
Plug 'udalov/kotlin-vim' " Kotlin Syntax Highlighting
Plug 'jackguo380/vim-lsp-cxx-highlight' " Cxx semantic highlighting
Plug 'lambdalisue/suda.vim'
Plug 'wesQ3/vim-windowswap'
call plug#end()
""" SUDA
let g:suda_smart_edit = 1 " Enable suda smart edit
""" Arduino
au BufRead,BufNewFile *.pde set filetype=arduino
au BufRead,BufNewFile *.ino set filetype=arduino
""" NERDTree
" Show NERDTree file manager
autocmd VimEnter * NERDTree | wincmd p
" Exit vim if NERDTree is last window
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') &&b:NERDTree.isTabTree() | quit | endif
let NERDTreeWinSize=30
let NERDTreeShowHidden=1
let NERDTreeIgnore=['^.git']
""" COC
so ~/.vim/coc.vim " (copied from example on https://github.com/neoclide/coc.nvim)
""" windowswap
let g:windowswap_map_keys = 0
nnoremap <silent> yw :call WindowSwap#MarkWindowSwap()<CR>
nnoremap <silent> pw :call WindowSwap#DoWindowSwap()<CR>
nnoremap <silent> ww :call WindowSwap#EasyWindowSwap()<CR>
""" Customize colors
func! s:my_colors_setup() abort
hi CocErrorFloat ctermfg=1
endfunc
augroup colorscheme_coc_setup | au!
au ColorScheme * call s:my_colors_setup()
augroup END
colorscheme custom
Xft.lcdfilter: lcddefault
Xft.antialias: true
Xft.rgba: rgb
Xft.dpi: 96
*font: xft:Inconsolata\ Nerd\ Font:size=10,xft:Inconsolata\ NF
*letterSpace: 0
URxvt*termName: rxvt-unicode
URxvt.scrollstyle: plain
URxvt.scrollBar_right: true
URxvt.iso14755: False
URxvt.perl-ext-common: default,clipboard,matcher,tabbed
URxvt.keysym.Shift-Control-C: perl:clipboard:copy
URxvt.keysym.Shift-Control-V: perl:clipboard:paste
URxvt.keysym.Home: \033[1~
URxvt.keysym.End: \033[4~
URxvt.keysym.KP_Home: \033[1~
URxvt.keysym.KP_End: \033[4~
URxvt.url-launcher: firefox
URxvt.matcher.button: 1
URxvt.colorUL: #7ECCB2
URxvt.internalBorder: 0
! generated from http://terminal.sexy
! special
*.foreground: #dcdcdc
*.background: #2d2d2d
*.cursorColor: #3d3d3d
! black
*.color0: #3d3d3d
*.color8: #535353
! red
*.color1: #d64937
*.color9: #f06860
! green
*.color2: #98c379
*.color10: #9ac392
! yellow
*.color3: #d79317
*.color11: #d9b676
! blue
*.color4: #3483e2
*.color12: #4376b6
! magenta
*.color5: #c678dd
*.color13: #c99be3
! cyan
*.color6: #5e8d87
*.color14: #8abeb7
! white
*.color7: #707880
*.color15: #b2b2b2
{
"diagnostic.errorSign": "\ufc63",
"diagnostic.warningSign": "\uf071",
"diagnostic.infoSign": "\uf05a",
"diagnostic.checkCurrentLine": true,
"diagnostic.separateRelatedInformationAsDiagnostics": true,
"diagnostic.maxWindowHeight": 16,
"clangd.fallbackFlags": ["-std=c++20"],
"clangd.semanticHighlighting": true,
"suggest.completionItemKindLabels": {
"keyword": "\uf1de",
"variable": "\ue79b",
"value": "\uf89f",
"operator": "\u03a8",
"constructor": "\uf0ad",
"function": "\u0192",
"reference": "\ufa46",
"constant": "\uf8fe",
"method": "\uf09a",
"struct": "\ufb44",
"class": "\uf0e8",
"interface": "\uf417",
"text": "\ue612",
"enum": "\uf435",
"enumMember": "\uf02b",
"module": "\uf40d",
"color": "\ue22b",
"property": "\ue624",
"field": "\uf9be",
"unit": "\uf475",
"event": "\ufacd",
"file": "\uf723",
"folder": "\uf114",
"snippet": "\ue60b",
"typeParameter": "\uf728",
"default": "\uf29c"
}
}
vim
" cool help screens
" :he group-name
" :he highlight-groups
" :he cterm-colors
if version > 580
" no guarantees for version 5.8 and below, but this makes it stop
" complaining
hi clear
if exists("syntax_on")
syntax reset
endif
endif
let g:colors_name="custom"
" there are nice definitions for what everything means here: https://github.com/joshdick/onedark.vim/blob/master/colors/onedark.vim
"
hi NonText cterm=bold ctermfg=15
hi Directory ctermfg=5
hi File ctermfg=7
hi LineNr ctermfg=1 ctermbg=None
" code
hi Comment ctermfg=7
hi Constant ctermfg=5
hi String ctermfg=5
hi Character ctermfg=5
hi Number ctermfg=4
hi Boolean ctermfg=1
hi Identifier ctermfg=15 " any variable name
hi Function ctermfg=4 " function and class names
hi Statement ctermfg=3
hi Conditional ctermfg=3 " if else statements
hi Repeat ctermfg=3 " loops
hi Label ctermfg=1 " case, default, etc
hi Operator ctermfg=15
hi Keyword ctermfg=3 " any other keyword
hi Exception ctermfg=1
hi PreProc ctermfg=7 " generic preprocessor
hi Include ctermfg=4
hi PreCondit ctermfg=5 " preprocessor #if etc
hi Type ctermfg=11
hi StorageClass ctermfg=3 " static, mutable, etc
hi Structure ctermfg=11
hi Typedef ctermfg=4
hi Special ctermfg=9
hi SpecialChar ctermfg=9 " special char in a constant
hi underlined cterm=underline
hi Error cterm=bold ctermfg=15 ctermbg=1
hi Todo ctermfg=3 ctermbg=8 cterm=italic
" Vim window
hi Pmenu ctermbg=0 ctermfg=15 " popup menu
hi PmenuSel ctermbg=8
hi PmenuSbar ctermbg=15
hi VertSplit cterm=NONE ctermfg=8
hi SignColumn ctermbg=NONE
hi StatusLine ctermbg=15 ctermfg=0
hi StatusLineNC ctermbg=15 ctermfg=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment