2018-02-28 02:31:44 +01:00
|
|
|
" New Start: A modern Arch workflow built with an emphasis on functionality.
|
2023-04-08 04:33:11 +02:00
|
|
|
" Copyright (C) 2017-2023 Donovan Glover
|
2018-02-28 02:31:44 +01:00
|
|
|
|
2018-10-31 17:28:54 +01:00
|
|
|
let plugsys = glob('/usr/share/vim/vimfiles/autoload/plug.vim')
|
|
|
|
let plugusr = glob('~/.vim/autoload/plug.vim')
|
|
|
|
|
|
|
|
if empty(plugsys) && empty(plugusr)
|
|
|
|
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
|
|
|
|
\ https://raw.githubusercontent.com/junegunn/vim-plug/0.10.0/plug.vim
|
|
|
|
endif
|
|
|
|
|
2022-01-02 02:51:03 +01:00
|
|
|
let g:ale_disable_lsp = 1
|
|
|
|
|
2022-07-29 16:36:19 +02:00
|
|
|
autocmd FileType javascript let g:ale_linters = {
|
|
|
|
\ 'javascript': glob('.eslintrc*', '.;') != '' ? [ 'eslint', 'flow' ] : [ 'standard', 'flow' ],
|
|
|
|
\}
|
|
|
|
|
2018-10-14 17:24:37 +02:00
|
|
|
call plug#begin('~/.vim/plugged')
|
|
|
|
Plug 'dylanaraps/wal.vim' " Color scheme
|
2022-01-02 02:52:18 +01:00
|
|
|
Plug 'preservim/nerdtree'
|
2018-10-14 17:24:37 +02:00
|
|
|
Plug 'airblade/vim-gitgutter' " Git diff
|
|
|
|
Plug 'itchyny/lightline.vim' " Status line
|
2022-07-29 16:34:48 +02:00
|
|
|
Plug 'dense-analysis/ale' " Syntax checker
|
2018-10-14 17:24:37 +02:00
|
|
|
Plug 'tpope/vim-fugitive' " Git wrapper
|
|
|
|
Plug 'junegunn/fzf.vim' " fzf wrapper
|
2021-08-01 21:01:43 +02:00
|
|
|
Plug 'lunarWatcher/auto-pairs' " {Pair} completion
|
2018-10-14 17:24:37 +02:00
|
|
|
Plug 'tpope/vim-endwise' " 'End' completion
|
|
|
|
Plug 'reedes/vim-pencil' " Word wrap
|
|
|
|
Plug 'junegunn/goyo.vim' " Distraction-free writing
|
2021-05-16 20:44:10 +02:00
|
|
|
Plug 'jparise/vim-graphql' " GraphQL support
|
2022-11-03 16:28:29 +01:00
|
|
|
Plug 'ryanoasis/vim-devicons'
|
2018-10-14 17:24:37 +02:00
|
|
|
|
2023-04-01 23:55:43 +02:00
|
|
|
Plug 'osyo-manga/vim-over'
|
2019-01-16 04:55:23 +01:00
|
|
|
Plug 'maksimr/vim-jsbeautify'
|
2018-10-14 17:24:37 +02:00
|
|
|
|
2023-04-01 23:55:43 +02:00
|
|
|
Plug 'pangloss/vim-javascript'
|
|
|
|
Plug 'rhysd/vim-crystal'
|
|
|
|
Plug 'rust-lang/rust.vim'
|
|
|
|
Plug 'baskerville/vim-sxhkdrc'
|
|
|
|
Plug 'dag/vim-fish'
|
|
|
|
Plug 'slim-template/vim-slim'
|
|
|
|
Plug 'Glench/Vim-Jinja2-Syntax'
|
|
|
|
Plug 'plasticboy/vim-markdown'
|
|
|
|
Plug 'posva/vim-vue'
|
|
|
|
Plug 'maxmellon/vim-jsx-pretty'
|
|
|
|
Plug 'digitaltoad/vim-pug'
|
|
|
|
Plug 'leafgarland/typescript-vim'
|
|
|
|
Plug 'dbeniamine/todo.txt-vim'
|
|
|
|
Plug 'lervag/vimtex'
|
|
|
|
Plug 'pantharshit00/vim-prisma'
|
|
|
|
Plug 'wuelnerdotexe/vim-astro'
|
2022-07-30 07:04:28 +02:00
|
|
|
Plug 'isobit/vim-caddyfile'
|
2018-10-14 17:24:37 +02:00
|
|
|
call plug#end()
|
|
|
|
|
2018-10-15 04:26:48 +02:00
|
|
|
" ============================
|
|
|
|
" ========= settings =========
|
|
|
|
" ============================
|
|
|
|
|
2018-10-14 17:24:37 +02:00
|
|
|
filetype plugin indent on " Attempt to determine the file type of extensionless files
|
|
|
|
syntax enable " Turn syntax highlighting on
|
|
|
|
|
|
|
|
set nocompatible " Use vim defaults (i.e. ignore vi compatibility)
|
|
|
|
set backspace=indent,eol,start " Make the backspace key function as you would expect
|
|
|
|
set encoding=utf-8 " Always show files as utf-8
|
|
|
|
set fileencoding=utf-8 " Ensure that we always save files as utf-8
|
2022-10-24 17:48:19 +02:00
|
|
|
set fileencodings=utf-8,sjis " Automatically open shiftjis files with their proper encoding
|
2018-10-14 17:24:37 +02:00
|
|
|
|
|
|
|
set autoindent " Automatically indent new lines
|
|
|
|
set ignorecase " By default use case-insensitive search (combine with smartcase)
|
|
|
|
set smartcase " Make search case-sensitive when using capital letters
|
|
|
|
set showcmd " Always show the current keybinding being executed
|
|
|
|
set spell " Enable spell check by default
|
2022-10-24 17:18:17 +02:00
|
|
|
set spelllang=en_us,cjk " Don't show errors for CJK characters
|
2018-10-14 17:24:37 +02:00
|
|
|
set hidden " Switch between buffers without saving them
|
|
|
|
|
|
|
|
set incsearch " Automatically move to text as you search for it
|
|
|
|
set wildmenu " Show a menu of the different options when you tab in command mode
|
|
|
|
set display+=lastline " Show as much of a long line as possible
|
|
|
|
set laststatus=2 " Enable the status line (set to 0 to remove)
|
|
|
|
set noshowmode " Disable the --MODE-- text (enable if not using the status line)
|
|
|
|
|
|
|
|
set history=100 " Only keep the last 100 commands
|
|
|
|
set tabpagemax=50 " Set the maximum number of tabs to be opened in any window to 50
|
|
|
|
set viminfo^=! " Use viminfo to store workspace and other data automatically
|
|
|
|
set sessionoptions-=options " When you explicitly save a workspace, save the entire environment
|
|
|
|
|
|
|
|
set t_Co=256 " Tell vim that we want to use 256 colors
|
|
|
|
set scrolloff=1 " The minimal number of rows to show when scrolling up/down
|
|
|
|
set sidescrolloff=5 " The minimal number of columns to show when scrolling left/right
|
|
|
|
|
|
|
|
set undofile " Keep track of undos even after you close a file
|
|
|
|
set undodir=~/.vim/undo " Save the undo history here (not that the directory must exist)
|
|
|
|
set undolevels=1000 " We can undo this many times
|
|
|
|
set undoreload=10000 " The maximum number of lines to keep in the undo file
|
|
|
|
|
|
|
|
set tabstop=4 " Show a tab character as 4 spaces
|
|
|
|
set softtabstop=0 " Edit soft tabs as if they're regular spaces
|
|
|
|
set shiftwidth=4 " Make autoindent appear as 4 spaces
|
|
|
|
|
|
|
|
set expandtab " When using <Tab>, replace the tab character with 4 spaces
|
|
|
|
set smarttab " Always indent based on column number to align things easier
|
|
|
|
|
|
|
|
set mouse=a " Enable mouse support in (a)ll modes
|
2022-01-02 02:54:09 +01:00
|
|
|
set number " Show numbers by default
|
2018-10-14 17:24:37 +02:00
|
|
|
|
2022-11-03 02:02:28 +01:00
|
|
|
" Disable middle button click
|
|
|
|
map <MiddleMouse> <Nop>
|
|
|
|
imap <MiddleMouse> <Nop>
|
|
|
|
map <2-MiddleMouse> <Nop>
|
|
|
|
imap <2-MiddleMouse> <Nop>
|
|
|
|
map <3-MiddleMouse> <Nop>
|
|
|
|
imap <3-MiddleMouse> <Nop>
|
|
|
|
map <4-MiddleMouse> <Nop>
|
|
|
|
imap <4-MiddleMouse> <Nop>
|
|
|
|
|
2018-10-15 04:26:48 +02:00
|
|
|
" ==========================
|
|
|
|
" ========= colors =========
|
|
|
|
" ==========================
|
2017-10-24 13:46:54 +02:00
|
|
|
|
2018-11-15 00:23:28 +01:00
|
|
|
" Set the color scheme to wal, or install plugins as needed.
|
|
|
|
try
|
|
|
|
colorscheme wal
|
|
|
|
catch /^Vim\%((\a\+)\)\=:E185/
|
|
|
|
echo "wal was not found. Installing plugins...\n" | PlugInstall --sync
|
|
|
|
echo "Plugins installed! You can now use vim.\n" | qa
|
|
|
|
endtry
|
2018-10-12 20:37:34 +02:00
|
|
|
|
2018-10-15 04:26:48 +02:00
|
|
|
" Don't show the separator for vertical splits
|
|
|
|
highlight vertsplit ctermfg=0 ctermbg=none
|
|
|
|
|
|
|
|
" Finally, an easier way to read search results
|
|
|
|
highlight Search ctermbg=240 ctermfg=255
|
|
|
|
highlight IncSearch ctermbg=255 ctermfg=240
|
|
|
|
|
|
|
|
" Easily show lines that go past the character count
|
2021-01-01 05:53:51 +01:00
|
|
|
" highlight OverLength ctermbg=240 ctermfg=230
|
|
|
|
" call matchadd('OverLength', '\%80v')
|
2018-10-15 04:26:48 +02:00
|
|
|
|
|
|
|
autocmd BufNewFile,BufRead *.ecr setlocal syntax=html
|
|
|
|
autocmd BufNewFile,BufRead *.slang setlocal filetype=slim
|
|
|
|
|
2018-10-19 07:07:27 +02:00
|
|
|
" =============================
|
|
|
|
" ========= lightline =========
|
|
|
|
" =============================
|
|
|
|
|
|
|
|
" Add the current branch to the status line
|
|
|
|
let g:lightline = {
|
|
|
|
\ 'active': {
|
|
|
|
\ 'left': [
|
|
|
|
\ [ 'mode', 'paste' ], [ 'gitbranch' ],
|
|
|
|
\ ['readonly', 'filename', 'modified']
|
|
|
|
\ ]
|
|
|
|
\ },
|
|
|
|
\ 'component_function': {
|
|
|
|
\ 'gitbranch': 'fugitive#head'
|
|
|
|
\ }
|
|
|
|
\ }
|
|
|
|
|
|
|
|
" Note that wal.vim's lightline theme uses some options that are incompatible
|
|
|
|
" with regular vim and are only supported by neovim.
|
|
|
|
"
|
|
|
|
" Wal Themes: Tomorrow, Tomorrow_Night, one, materia, material, nord
|
|
|
|
" Other Themes: wombat, solarized, powerline, jellybeans, Tomorrow_Night_Blue,
|
|
|
|
" Tomorrow_Night_Eighties, PaperColor, seoul256, landscape,
|
|
|
|
" darcula, molokai, OldHope, deus
|
|
|
|
if has('nvim')
|
|
|
|
let g:lightline.colorscheme = 'wal'
|
|
|
|
else
|
|
|
|
let g:lightline.colorscheme = 'Tomorrow_Night'
|
|
|
|
endif
|
|
|
|
|
2023-01-07 09:37:02 +01:00
|
|
|
" Make background color of lightline match terminal
|
|
|
|
" https://github.com/itchyny/lightline.vim/issues/168
|
|
|
|
autocmd VimEnter * call SetupLightlineColors()
|
|
|
|
function SetupLightlineColors() abort
|
|
|
|
" transparent background in statusbar
|
|
|
|
let l:palette = lightline#palette()
|
|
|
|
|
|
|
|
let l:palette.normal.middle = [ [ 'NONE', 'NONE', 'NONE', 'NONE' ] ]
|
|
|
|
let l:palette.inactive.middle = l:palette.normal.middle
|
|
|
|
let l:palette.tabline.middle = l:palette.normal.middle
|
|
|
|
|
|
|
|
call lightline#colorscheme()
|
|
|
|
endfunction
|
|
|
|
|
2018-10-15 04:26:48 +02:00
|
|
|
" ============================
|
|
|
|
" ========= keybinds =========
|
|
|
|
" ============================
|
|
|
|
|
|
|
|
" Use space as the global leader
|
|
|
|
let mapleader = ' '
|
|
|
|
|
|
|
|
" Top row
|
|
|
|
nnoremap <silent> <leader>e :set nu!<CR>
|
|
|
|
nnoremap <silent> <leader>t :OverCommandLine<CR>%s/
|
|
|
|
|
|
|
|
" Middle row
|
2018-10-18 20:10:41 +02:00
|
|
|
nnoremap <silent> <leader>a :Vexplore<CR>
|
|
|
|
nnoremap <silent> <leader>s :Sexplore<CR>
|
|
|
|
nnoremap <silent> <leader>d :Explore<CR>
|
2018-10-15 04:26:48 +02:00
|
|
|
nnoremap <silent> <leader>f :Files<CR>
|
|
|
|
nnoremap <silent> <leader>g :set hlsearch!<CR>
|
|
|
|
nnoremap <silent> <leader>j :Buffers<CR>
|
2023-01-07 07:28:42 +01:00
|
|
|
nnoremap <silent> <leader>k :NERDTreeToggleVCS<CR>
|
2018-10-15 04:26:48 +02:00
|
|
|
nnoremap <silent> <leader>l :Rg<CR>
|
2023-01-07 07:28:42 +01:00
|
|
|
nnoremap <silent> <leader>; <C-w>w
|
2018-10-15 04:26:48 +02:00
|
|
|
|
|
|
|
" Bottom row
|
|
|
|
autocmd FileType javascript nnoremap <silent> <leader>b :call JsBeautify()<CR>
|
|
|
|
autocmd FileType json nnoremap <silent> <leader>b :call JsonBeautify()<CR>
|
|
|
|
autocmd FileType jsx nnoremap <silent> <leader>b :call JsxBeautify()<CR>
|
|
|
|
autocmd FileType html nnoremap <silent> <leader>b :call HtmlBeautify()<CR>
|
|
|
|
autocmd FileType css nnoremap <silent> <leader>b :call CSSBeautify()<CR>
|
|
|
|
|
2023-01-07 09:50:15 +01:00
|
|
|
" Experimental yomichan-like command with tango
|
|
|
|
vnoremap <C-s> y:silent !notify-send -t 4000 "成果" "$(tango '<C-r>0')"<CR>:<Esc>
|
|
|
|
|
2018-10-15 04:26:48 +02:00
|
|
|
" Easily enter 'zen mode' with Goyo and Pencil (Note: Goyo resets the color scheme)
|
|
|
|
nnoremap <silent> <leader>2 :PencilSoft<CR>:Goyo<CR>:hi vertsplit ctermfg=0 ctermbg=none<CR>
|
|
|
|
|
|
|
|
" Save and load vim sessions
|
|
|
|
nnoremap <silent> <leader>3 :mksession! ~/.vim/.session<CR>
|
|
|
|
nnoremap <silent> <leader>4 :source ~/.vim/.session<CR>
|
|
|
|
|
2022-12-15 17:41:46 +01:00
|
|
|
" Never worry about a directory not being created before saving
|
|
|
|
autocmd BufWritePre,FileWritePre * silent! call mkdir(expand('<afile>:p:h'), 'p')
|
|
|
|
|
2018-10-18 20:10:41 +02:00
|
|
|
" =========================
|
|
|
|
" ========= netrw =========
|
|
|
|
" =========================
|
|
|
|
|
|
|
|
" Remove the banner
|
|
|
|
let g:netrw_banner = 0
|
|
|
|
|
|
|
|
" Use the tree list view
|
|
|
|
let g:netrw_liststyle = 3
|
|
|
|
|
2018-10-15 04:26:48 +02:00
|
|
|
" =======================
|
|
|
|
" ========= ale =========
|
|
|
|
" =======================
|
2017-10-24 13:46:54 +02:00
|
|
|
|
2022-01-02 02:51:03 +01:00
|
|
|
nmap <silent> <C-j> <Plug>(ale_previous_wrap)
|
|
|
|
nmap <silent> <C-k> <Plug>(ale_next_wrap)
|
2017-12-25 00:33:50 +01:00
|
|
|
|
2018-10-15 04:26:48 +02:00
|
|
|
" ==========================
|
|
|
|
" ========= vimtex =========
|
|
|
|
" ==========================
|
2017-12-25 00:33:50 +01:00
|
|
|
|
2018-10-15 04:26:48 +02:00
|
|
|
" Disable all keybinds so we can define our own
|
2017-12-25 00:33:50 +01:00
|
|
|
let g:vimtex_mappings_enabled = 0
|
|
|
|
let g:vimtex_imaps_enabled = 0
|
|
|
|
let g:vimtex_view_method = 'zathura'
|
2018-01-07 05:55:51 +01:00
|
|
|
let g:vimtex_compiler_latexmk = {'build_dir': '.tex'}
|
2018-10-15 04:26:48 +02:00
|
|
|
|
|
|
|
" Set the normal keybinds
|
2018-10-14 01:42:56 +02:00
|
|
|
nnoremap <localleader>f <plug>(vimtex-view)
|
|
|
|
nnoremap <localleader>g <plug>(vimtex-compile)
|
|
|
|
nnoremap <localleader>d <plug>(vimtex-env-delete)
|
|
|
|
nnoremap <localleader>c <plug>(vimtex-env-change)
|
2017-12-25 00:33:50 +01:00
|
|
|
|
2018-10-15 04:26:48 +02:00
|
|
|
" ================================
|
|
|
|
" ========= vim-markdown =========
|
|
|
|
" ================================
|
2018-04-09 23:28:36 +02:00
|
|
|
|
|
|
|
" Disable vim-markdown folding
|
|
|
|
let g:vim_markdown_folding_disabled = 1
|
2018-10-14 01:42:56 +02:00
|
|
|
let g:vim_markdown_math = 1
|
|
|
|
let g:vim_markdown_frontmatter = 1
|
2018-04-09 23:28:36 +02:00
|
|
|
autocmd BufNewFile,BufRead *.md set conceallevel=2
|
|
|
|
|
2018-08-31 19:43:14 +02:00
|
|
|
" Ignore syntax concealing for markdown files
|
|
|
|
let g:vim_markdown_conceal = 0
|
|
|
|
let g:tex_conceal = ""
|
|
|
|
let g:vim_markdown_math = 1
|
2018-10-14 01:42:56 +02:00
|
|
|
|
2023-01-07 07:28:42 +01:00
|
|
|
" ============================
|
|
|
|
" ========= nerdtree =========
|
|
|
|
" ============================
|
|
|
|
|
|
|
|
let NERDTreeShowHidden=1
|
|
|
|
|
|
|
|
" Start NERDTree. If a file is specified, move the cursor to its window.
|
|
|
|
autocmd StdinReadPre * let s:std_in=1
|
|
|
|
autocmd VimEnter * silent! lcd %:p:h | NERDTreeVCS | wincmd p
|
|
|
|
|
|
|
|
" Exit if NERDTree is the only window remaining in the only tab.
|
|
|
|
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
|
|
|
|
|
|
|
let NERDTreeStatusline='%{exists("b:NERDTree")?fnamemodify(b:NERDTree.root.path.str(), ":~"):""}'
|
|
|
|
|
2018-10-15 04:26:48 +02:00
|
|
|
" ===========================
|
|
|
|
" ========= fzf.vim =========
|
|
|
|
" ===========================
|
|
|
|
|
2018-10-14 01:42:56 +02:00
|
|
|
" Hide the status line showing "fzf" when using fzf.vim
|
|
|
|
" NOTE: You must add "showmode" if your setup depends on it
|
|
|
|
autocmd! FileType fzf
|
|
|
|
autocmd FileType fzf set laststatus=0 noshowmode noruler
|
|
|
|
\| autocmd BufLeave <buffer> set laststatus=2 ruler
|