Neovim Configurations
Neovim is an incredibly powerful tool for editing documents, editing code, file manipulation, uploading files to GitHub, and more!
Despite Neovim’s utility, getting the most out of it involves spending a great deal of time on configuration and tinkering.
To save others that trouble and to demonstrate more concretely how I use Neovim myself, included here is a copy of my own custom configuration. Simply ensure you have the latest version of Neovim installed on one’s machine, and take care to install any dependencies including Python3, Okular, and latexmk.
nvim/init.vim
" Basic Configuration Options
set nocompatible
set showmatch
set hlsearch
set expandtab
set shiftwidth=4
set autoindent
set number
set wildmode=longest,list
syntax on
syntax enable
set mouse=a
set clipboard=unnamedplus
filetype plugin on
filetype plugin indent on
set cursorline
set ttyfast
set encoding=utf8
" set spell
" set noswapfile
" set backupdir=~/.cache/vim
" Automatically loading Vim-Plug on Startup
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir. '/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Vim-Plug - Plugin Manager
call plug#begin()
Plug 'joshdick/onedark.vim'
Plug 'ryanoasis/vim-devicons'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'nvim-tree/nvim-web-devicons'
Plug 'lambdalisue/fern.vim'
Plug 'lambdalisue/vim-fern-hijack'
Plug 'mhinz/vim-startify'
Plug 'ellisonleao/glow.nvim'
Plug 'tpope/vim-fugitive'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim', {'tag': '0.1.8'}
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-neorg/neorg'
Plug 'nvim-neorocks/rocks.nvim'
Plug 'lervag/vimtex'
Plug 'lervag/vimtex', { 'tag': 'v2.15' }
call plug#end()
colorscheme onedark
" Lua Lines - Used for Neorg & Markdown Previews respectively
lua << EOF
require('glow').setup()
EOF
" Autoinstall New Plugins "
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
let g:python3_host_prog = '/usr/bin/python3'
let g:python_host_prog = '/usr/bin/python'
" VimTex Block - Necessary for Tex functions to work properly "
let g:vimtex_view_general_viewer = 'okular'
let g:vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex'
let g:vimtex_compiler_method = 'latexmk'
" Startify Block - Startup Screen "
let g:startify_padding_left = 3
let g:startify_enable_special = 0
let g:startify_fortune_use_unicode = 1
let g:ascii = [
\'',
\' dMMMMb dMMMMMP .aMMMb dMP dMP dMP dMMMMMMMMb ',
\' dMP dMP dMP dMP"dMP dMP dMP amr dMP"dMP"dMP',
\' dMP dMP dMMMP dMP dMP dMP dMP dMP dMP dMP dMP ',
\' dMP dMP dMP dMP.aMP YMvAP" dMP dMP dMP dMP ',
\' dMP dMP dMMMMMP VMMMP" VP" dMP dMP dMP dMP ',
\'',
\]
let g:startify_custom_header = g:ascii
let g:startify_commands = [
\ {'f': ['File Explorer', ':$tabnew | :Fern /home/gareth']},
\ {'d': ['Downloads', ':$tabnew | :Fern /home/gareth/Downloads/']},
\ {'l': ['Documents', ':$tabnew | :Fern /home/gareth/Documents/LaTeX/']},
\ {'n': ['Notes', ':$tabnew | :Neorg workspace notes']},
\ {'k': ['Keyboard Firmware', ':$tabnew | :e ~/qmk_firmware/keyboards/kiraibuilds/']},
\ {'i': ['Install Plugins', ':$tabnew | PlugInstall']},
\ {'u': ['Update Plugins', ':$tabnew | PlugUpdate | PlugUpgrade']},
\ {'c': ['Edit Neovim Config', ':$tabnew | :e ~/.config/nvim/init.vim']},
\ {'p': ['Edit Plugin Config', ':$tabnew | :e ~/.config/nvim/plugin/init.lua']},
\ {'h': ['Full Documentation', ':$tabnew | :help']},
\ {'t': ['Neovim Tutorial', ':$tabnew | :Tutor']},
\ ]
let g:startify_lists = [
\ {'type': 'files', 'header': [' Most Recent Files']},
\ {'type': 'commands', 'header': [' Quick Options Menu']},
\ ]
let g:startify_files_number = 6
let g:startify_session_persistence = 1
nvim/plugin/init.lua
local rocks_config = {
rocks_path = vim.env.HOME .. "/.local/share/nvim/rocks",
}
vim.g.rocks_nvim = rocks_config
local luarocks_path = {
vim.fs.joinpath(rocks_config.rocks_path, "share", "lua", "5.1", "?.lua"),
vim.fs.joinpath(rocks_config.rocks_path, "share", "lua", "5.1", "?", "init.lua"),
}
package.path = package.path .. ";" .. table.concat(luarocks_path, ";")
local luarocks_cpath = {
vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.so"),
vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.so"),
vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.dylib"),
vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.dylib"),
vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.dll"),
vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.dll"),
}
package.cpath = package.cpath .. ";" .. table.concat(luarocks_cpath, ";")
vim.opt.runtimepath:append(vim.fs.joinpath(rocks_config.rocks_path, "lib", "luarocks", "rocks-5.1", "rocks.nvim", "*"))
require("neorg").setup({
load = {
["core.defaults"] = {},
["core.dirman"] = {
config = {
workspaces = {
notes = "~/notes",
},
},
},
},
})