0
0

Modified nvim role

This commit is contained in:
Opnxng 2023-11-18 21:00:10 +08:00
parent be863a951d
commit 31fb9a6ba9
2 changed files with 12 additions and 265 deletions

View File

@ -1,254 +0,0 @@
" Basic configurations
set nocompatible
set novisualbell
syntax on
set encoding=utf-8
set number
set clipboard=unnamedplus
set textwidth=100
" Set to I-beam cursor
" set guicursor=v-c-sm:block,n-i-ci-ve:ver25,r-cr-o:hor20
" , is leader
let mapleader =","
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remaps for Smart Quit
nnoremap ZZ :w<CR>:SmartQ<CR>
nnoremap ZQ <Plug>(smartq_this)
" Remaps for buffers
nnoremap <C-j> :bprevious<CR>
nnoremap <C-k> :bnext<CR>
nnoremap <leader>b :Buffer<CR>
" Remaps for line numbers toggle
nmap <C-N><C-N> :set invnumber<CR>
" Other remaps
nnoremap F :Files<CR>
imap jj <Esc>
set backspace=indent,eol,start
nnoremap S :%s///g<Left><Left><Left>
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
map <F3> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" . " FG:" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"fg#")<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable autocompletion:
set wildmode=longest,list,full
" Spell-check set to <leader>o, 'o' for 'orthography':
map <leader>o :setlocal spell! spelllang=en_us<CR>
" Disables automatic commenting on newline:
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" Indentations
set softtabstop=2
set shiftwidth=2
set expandtab
filetype plugin indent on
" set smartindent
" set smarttab
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Splits open at the bottom and right, which is non-retarded, unlike vim defaults.
set splitbelow splitright
" Search and Replace
set ignorecase
set smartcase
set nohlsearch
set incsearch
" set hlsearch
" Edit .j2 as yaml files
au BufNewFile,BufReadPost *.yaml.j2 set filetype=yaml
au BufNewFile,BufReadPost *.yml.j2 set filetype=yaml
" Remove trailing whitespace
autocmd BufWritePre * %s/\s\+$//e
" Whitespace as shown as dots
set list
set listchars=lead,trail,tab:»\ ,extends,precedes,nbsp
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
call plug#begin()
Plug 'junegunn/goyo.vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'marklcrns/vim-smartq'
call plug#end()
" Smartq
let g:smartq_default_mappings = 0
" Goyo
autocmd vimenter * Goyo 100
function! s:goyo_enter()
set linebreak
set wrap
let b:quitting = 0
let b:quitting_bang = 0
autocmd QuitPre <buffer> let b:quitting = 1
cabbrev <buffer> q! let b:quitting_bang = 1 <bar> q!
endfunction
function! s:goyo_leave()
" Quit Vim if this is the only remaining buffer
if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1
if b:quitting_bang
qa!
else
qa
endif
endif
endfunction
autocmd! User GoyoEnter call <SID>goyo_enter()
autocmd! User GoyoLeave call <SID>goyo_leave()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Colours
" Bash
highlight shCmdSubRegion ctermfg=Magenta
highlight shCmdSub ctermfg=Magenta
highlight shCommandSub ctermfg=Magenta
highlight shDerefSimple ctermfg=Brown
highlight shNumber ctermfg=Cyan
highlight shIf ctermfg=Magenta
highlight shElse ctermfg=Magenta
highlight shElif ctermfg=Magenta
highlight shFi ctermfg=Magenta
highlight shFor ctermfg=Magenta
highlight shWhile ctermfg=Magenta
highlight shFunction ctermfg=Magenta
highlight shCase ctermfg=Magenta
highlight shEsac ctermfg=Magenta
highlight shReturn ctermfg=Magenta
highlight shVariable ctermfg=Blue
highlight shString ctermfg=Green
highlight shSpecial ctermfg=Brown
highlight shDerefVar ctermfg=Brown
highlight PreProc ctermfg=Brown
highlight shNumber ctermfg=Cyan
highlight shDanger ctermfg=Red
" Yaml
highlight yamlBlockMappingKey ctermfg=Magenta
highlight yamlKeyValueDelimiter ctermfg=Magenta
highlight yamlBlock ctermfg=Magenta
highlight yamlKey ctermfg=Blue
highlight yamlDoubleQuotedString ctermfg=Cyan
highlight yamlSingleQuotedString ctermfg=Cyan
highlight yamlDocumentHeader ctermfg=Brown
highlight yamlTag cterm=italic
highlight yamlFlowIndicator ctermfg=White
" CSS
highlight cssClassName ctermfg=Magenta
highlight cssIdSelector ctermfg=Magenta
highlight cssAttributeSelector ctermfg=Magenta
highlight cssMediaQuery ctermfg=Blue
highlight cssKeyframeRule ctermfg=Blue
highlight cssAnimationProperty ctermfg=Magenta
highlight cssVariable ctermfg=Blue
highlight cssVendorProperty ctermfg=Brown
highlight cssImportantKeyword ctermfg=Brown
highlight cssFontProp ctermfg=Magenta
highlight cssFontDescriptorProp ctermfg=Magenta
highlight cssAtKeyword ctermfg=Magenta
highlight cssFunctionName ctermfg=Magenta
highlight cssAtRule ctermfg=Blue
highlight cssPseudoClassId ctermfg=Blue
highlight cssSelector cterm=italic
highlight cssProperty cterm=italic
highlight cssValue cterm=italic
highlight cssNumber ctermfg=Cyan
highlight cssTrue ctermfg=Cyan
highlight cssFalse ctermfg=Cyan
highlight cssNull ctermfg=Cyan
highlight cssCustomProp ctermfg=Magenta
highlight cssTextProp ctermfg=DarkYellow
" Python
highlight pythonFunction cterm=italic
highlight pythonClass cterm=italic
highlight pythonMethod cterm=italic
" JavaScript
highlight jsFunction cterm=italic
highlight jsClass cterm=italic
highlight jsMethod cterm=italic
" HTML
highlight htmlTag cterm=italic
highlight htmlAttribute cterm=italic
" Java
highlight javaClass cterm=italic
highlight javaMethod cterm=italic
highlight javaFunction cterm=italic
" Vimscript
highlight vimParen ctermfg=White
highlight vimSep ctermfg=White
highlight vimBraces ctermfg=White
highlight vimFunc ctermfg=Cyan
highlight vimNotation ctermfg=Cyan
highlight vimBracket ctermfg=Cyan
highlight vimMapModKey ctermfg=Cyan
highlight vimSetOption ctermfg=Cyan
highlight vimAutoCommand ctermfg=Cyan
highlight vimUserCommand ctermfg=Cyan
highlight vimCommand ctermfg=Cyan
highlight vimFuncSID ctermfg=Cyan
highlight vimMapKey ctermfg=Cyan
highlight vimOption ctermfg=Blue
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Colours
" Use purple for syntax elements
highlight Keyword ctermfg=Magenta
highlight Statement ctermfg=Magenta
" Use blue for variables
highlight Identifier ctermfg=Blue
highlight Type ctermfg=Blue
highlight Function ctermfg=Blue
" Use teal for numbers and language constants
highlight Number ctermfg=Cyan
highlight Boolean ctermfg=Cyan
highlight Constant ctermfg=Cyan
" Use green for string literals
highlight String ctermfg=Green
" Use orange for special syntax elements
highlight Special ctermfg=Brown
" Use red to highlight errors
highlight Error ctermfg=White ctermbg=Red
highlight Danger ctermfg=White ctermbg=Red
" Use grey for comments
highlight Comment ctermfg=DarkGrey
" Match parentheses
highlight MatchParen ctermfg=White
" Curly braces, square brackets, parentheses
highlight Delimiter ctermfg=White
highlight Indicator ctermfg=White
highlight SpecialChar ctermfg=White
highlight SpecialComment ctermfg=White
" Use italics for computation
highlight yamlKey cterm=italic
highlight yamlValue cterm=italic
highlight yamlAnchor cterm=italic
highlight NonText ctermfg=DarkGrey
highlight SpecialKey ctermfg=DarkGrey
highlight StatusLine ctermbg=White ctermfg=DarkGrey
highlight LineNr ctermfg=DarkGrey

View File

@ -29,10 +29,10 @@
become_method: sudo become_method: sudo
become_user: "{{ user }}" become_user: "{{ user }}"
- name: Copy init.vim - name: Copy nvim config
copy: copy:
src: "init.vim" src: "/home/{{ user }}/.config/nvim/"
dest: "/home/{{ user }}/.config/nvim/init.vim" dest: "/home/{{ user }}/.config/nvim/"
owner: 1000 owner: 1000
group: 1000 group: 1000
mode: "0755" mode: "0755"
@ -40,14 +40,6 @@
become_method: sudo become_method: sudo
become_user: "{{ user }}" become_user: "{{ user }}"
- name: Download Vim Plug
command: >
sh -c 'curl -fLo "/home/{{ user }}/.local/share/nvim/site/autoload/plug.vim"
--create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
become: yes
become_method: sudo
become_user: "{{ user }}"
- name: Install Vim Plug - name: Install Vim Plug
command: > command: >
vim -u /home/{{ user }}/.config/nvim/init.vim +'PlugInstall --sync' +qa vim -u /home/{{ user }}/.config/nvim/init.vim +'PlugInstall --sync' +qa
@ -56,3 +48,12 @@
become: yes become: yes
become_method: sudo become_method: sudo
become_user: "{{ user }}" become_user: "{{ user }}"
- name: Uninstall Vim Plug
command: >
vim -u /home/{{ user }}/.config/nvim/init.vim +'PlugClean --sync' +qa
args:
creates: "/home/{{ user }}/.config/nvim/plugged"
become: yes
become_method: sudo
become_user: "{{ user }}"