Skip to content

Instantly share code, notes, and snippets.

@devcharmander
Last active April 3, 2022 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devcharmander/d02accf41ad5c50e4d1d14be9ba0bf32 to your computer and use it in GitHub Desktop.
Save devcharmander/d02accf41ad5c50e4d1d14be9ba0bf32 to your computer and use it in GitHub Desktop.
nvim config for journaling
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
endif
" Set automatic relative line numbers
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu && mode() != "i" | set rnu | endif
autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif
augroup END
" Run PlugInstall if there are missing plugins
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
\| PlugInstall --sync | source $MYVIMRC
\| endif
call plug#begin('~/.config/nvim/plugged')
"Color:
Plug 'EdenEast/nightfox.nvim'
"Fancy Stuff:
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
"Journaling:
Plug 'vimwiki/vimwiki'
"Staus Line:
Plug 'nvim-lualine/lualine.nvim'
Plug 'kyazdani42/nvim-web-devicons'
call plug#end()
"COPY/PASTE:
"-----------
"Increases the memory limit from 50 lines to 1000 lines
:set viminfo='100,<1000,s10,h
"Color:
set termguicolors
colorscheme nordfox
lua << END
require('lualine').setup()
END
"NUMBERING:
"----------
:set number
"INDENTATION:
"------------
"Highlights code for multiple indents without reselecting
vnoremap < <gv
vnoremap > >gv
"NAVIGATION:
"----------
nmap <silent> <A-Up> :wincmd k<CR>
nmap <silent> <A-Down> :wincmd j<CR>
nmap <silent> <A-Left> :wincmd h<CR>
nmap <silent> <A-Right> :wincmd l<CR>
nmap <space> <Plug>(SmoothieDownwards)
"-------------
"Cycle through completion entries with tab/shift+tab
inoremap <expr> <TAB> pumvisible() ? "\<c-n>" : "\<TAB>"
inoremap <expr> <s-tab> pumvisible() ? "\<c-p>" : "\<TAB>"
"Allow getting out of pop with Down/Up arrow keys
inoremap <expr> <down> pumvisible() ? "\<C-E>" : "\<down>"
inoremap <expr> <up> pumvisible() ? "\<C-E>" : "\<up>"
"Replace ESC with jj
inoremap jj <esc>
"-------------
"SHORTCUTS:
"----------
"Open file at same line last closed
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif
"SOURCING:
"---------
"Automatically reloads neovim configuration file on write (w)
autocmd! bufwritepost init.vim source %
"MOUSE:
"------
"Allow using mouse helpful for switching/resizing windows
set mouse+=a
if &term =~ '^screen'
" tmux knows the extended mouse mode
set ttymouse=xterm2
endif
"TEXT SEARCH:
"------------
"Makes Search Case Insensitive
set ignorecase
"SWAP:
"-----
set dir=~/.local/share/nvim/swap/
"SYNTAX HIGHLIGHTING:
"--------------------
syntax on
"HIGHLIGHTING:
"-------------
" <Ctrl-l> redraws the screen and removes any search highlighting.
nnoremap <silent> <C-l> :nohl<CR><C-l>
"Prettier:
"-------------
command! -nargs=0 Prettier :call CocAction('runCommand', 'prettier.formatFile')
"Copy To CLipboard:
"------------------
vnoremap y "+y
nnoremap Y "+yg_
nnoremap y "+y
nnoremap yy "+yy
"Paste From Clipboard:
"---------------------
nnoremap <S-p> "+p
nnoremap <S-P> "+P
vnoremap <S-p> "+p
vnoremap <S-P> "+P
"Wiki:
"------
set nocompatible
filetype plugin on
syntax on
function! LoadQuotes()
let quote = systemlist('gshuf -n 1 ~/vimwiki/quotes')
return ">_" . quote[0] . "_"
endfunction
function! JournalHeader()
return "# " . strftime('%a') . " " . strftime('%m/%d') . " @"
endfunction
nmap <Space>l :r ~/vimwiki/demo_template.md<CR>gg"=JournalHeader()<C-M>p2j"=LoadQuotes()<C-M>pgg
let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown', 'ext': '.md'}]
let g:lexical#spelllang = ['en_us','en_gb',]
:au VimEnter * VimwikiDiaryIndex
:au VimEnter * if exists(':Goyo') | Goyo | endif
:au VimEnter * if exists(':Limelight') | Limelight | endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment