DEVZGQYDMMD2ZMJKQX5M72L4LTYAZEIVEDXSYNIMHMRBT5CJIERAC
3BK5VANZFIJ3MOFXL66FHO372G3XSVJP6YJFXW24KY4QL62MHLTAC
MTBVSWE2XCQ3F3MBM2Q6H5BU5TYJPRKQVPYNUG7TAD4TEFKDUEKQC
YSKR5RAG56GA3T554X2S5QNFQSHAYFXU3QT5QMU5A5OUGLPAMJ2AC
4LSO4STLQJZ7TXVI3BYUXAG7UV3LAICU65B52RUKABD3KHQ2G7GAC
ULKBUZEBFCZOZ5BTUW6262LG5DK6BUOVN6STTKCFLZFG3EE6PFPAC
QWJ5FBQ7ZL75GTXLYEVPTLK7AEMBMBEYE7536WFLGINTG332LAIAC
UNMO22GQRCYHMIXPFTZTQVVPCOFSBVU2YV5CKLO72ZRDZ2AJ46WQC
AD3GGMJYYDKYXMTBCQK7IHKTVSM75XFTBHZSMFXFAQYWSPRHSCBAC
PS5PXTHFTQDM4WVNMXEJUPLQVGQWULYJ5IVAXZ7LJX4ZUSICUKDAC
XCR34YPGC3GY7CKQTQX4WUEKLRLAZKNSUPWOKGD5HUHK2RN7RKGAC
5U2BEZGMRUSG3OQM3VGNF3XINPCKRLGU7CJJDUVRHHORN3IED2HQC
JTTWOADMNTGEUL5TBJSC5PEXSW6GMBZLY6TWLN2DHV26REVMZOZAC
K5EUTRJG3IQJGSDDG3WVBYKQOOR5MIXHQG3JDSQXDEBAQLSGV7EQC
HWLVSY6UL5VDMK7NLQB2LJYEHV6KNKP4QIUWJKYTKKYW3L5ZLQBAC
" show existing tab with 2 spaces width
setlocal tabstop=2
" when indenting with '>', use 2 spaces width
" also sets the number of spaces to be inserted b/c softtabstop=-1
setlocal shiftwidth=2
" the above wasn't working...?
setlocal tabstop=2 softtabstop=-1 expandtab shiftwidth=2 smarttab
" Show whitespace
set list
set listchars=tab:→\ ,space:·,nbsp:␣,trail:•,eol:¶,precedes:«,extends:»
" Line number gutter configuration
set number relativenumber
" Show when I'm in an open fold
set foldcolumn=1
" Automatically close folds when leaving them
set foldclose=all
" Keep the cursor 10 lines from the top/bottom of the screen
set scrolloff=10
" Automatically hit enter for me
set textwidth=80
set completeopt=noinsert,menuone,noselect
set shortmess+=c " avoid extra messages during completion
set pumheight=20 " display 20 items at most
" use normal regex when searching in normal/visual mode
nnoremap / /\v
" search for highlighted text when entering search from visual mode
vnoremap / y/\V<c-r>=escape(@",'/\')<cr><cr>
"{{{ Plugin Options
" highlight the buffer line
highlight link BufferCurrent Title
highlight link BufferCurrentMod Title
highlight link BufferCurrentSign Title
highlight link BufferCurrentIndex Title
highlight link BufferCurrentTarget Title
let bufferline = get(g:, 'bufferline', {})
let bufferline.animation = v:false
let bufferline.icons = v:false
" showmode hides the echodoc function signatures,
" and airline already shows the mode
set noshowmode
" persist undo history between sessions
set undofile
set undodir=~/.local/share/nvim/undo/
" List all open buffers at the top of the screen
let g:airline#extensions#tabline#enabled = 1
" Trigger completion with <Tab>
inoremap <silent><expr> <tab>
\ pumvisible() ? "\<c-n>" :
\ <sid>check_back_space() ? "\<tab>" :
\ completion#trigger_completion()
inoremap <silent><expr> <s-tab>
\ pumvisible() ? "\<c-p>" :
\ <sid>check_back_space() ? "\<s-tab>" :
\ completion#trigger_completion()
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
" highlight yanked text
au TextYankPost * lua vim.highlight.on_yank {on_visual = false, timeout = 200}
" Enable type inlay hints
autocmd CursorMoved,InsertLeave,BufEnter,BufWinEnter,TabEnter,BufWritePost *
\ lua require'lsp_extensions'.inlay_hints{prefix = '', highlight = "NonText"}
" set up the lsp settings for each language upon entering a buffer
:lua << EOF
local lspconfig = require('lspconfig')
local buf_set_keymap = vim.api.nvim_buf_set_keymap
local capabilities = {
textDocument = {
completion = {
completionItem = {
snippetSupport = false
}
}
}
}
local on_attach = function(client, bufnr)
require('completion').on_attach(client)
local opts = { noremap=true, silent=true }
-- there are several goto def/impl/decl actions. this first one is my favorite
buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
buf_set_keymap(bufnr, 'n', '<c-]>', '<cmd>lua vim.lsp.buf.definition()<cr>', opts) -- the traditional mapping
buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
buf_set_keymap(bufnr, 'n', '<c-k>', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
buf_set_keymap(bufnr, 'n', '1gD', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
buf_set_keymap(bufnr, 'n', 'g0', '<cmd>lua vim.lsp.buf.document_symbol()<cr>', opts)
buf_set_keymap(bufnr, 'n', 'gW', '<cmd>lua vim.lsp.buf.workspace_symbol()<cr>', opts)
buf_set_keymap(bufnr, 'n', '<localleader>r', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
buf_set_keymap(bufnr, 'n', '<localleader>d', '<cmd>lua vim.lsp.util.show_line_diagnostics()<cr>', opts)
-- configuration for diagnostics
buf_set_keymap(bufnr, 'n', 'g[', '<cmd>lua vim.lsp.diagnostic.goto_prev()<cr>', opts)
buf_set_keymap(bufnr, 'n', 'g]', '<cmd>lua vim.lsp.diagnostic.goto_next()<cr>', opts)
-- TODO: add a mapping for goto implementation
-- buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
end
local servers = {
["rust_analyzer"] = {},
["pyls"] = {},
["clangd"] = {},
["gopls"] = {},
["tsserver"] = {},
["texlab"] = {},
["bashls"] = {},
["html"] = {},
["cssls"] = {}
}
for lsp, setup_config in pairs(servers) do
-- these settings are shared among all the servers
setup_config.on_attach = on_attach
setup_config.capabilities = capabilities
lspconfig[lsp].setup(setup_config)
end
EOF
set completeopt=noinsert,menuone,noselect
set shortmess+=c " avoid extra messages during completion
set pumheight=20 " display 20 items at most
let g:completion_chain_complete_list = {
\'default' : [
\ {'complete_items': ['lsp', 'snippet', 'path']},
\ {'mode': '<c-p>'},
\ {'mode': '<c-n>'}
\]
\}
" Enable and select color schemes
syntax on
colorscheme onedark
let g:airline_theme = 'onedark'
let g:airline_section_z = '%l/%L :%c'
" create a homerow shortcut for escape
inoremap <silent> <c-space> <esc>
vnoremap <silent> <c-space> <esc>
nnoremap <silent> <c-space> <esc>
snoremap <silent> <c-space> <esc>
tnoremap <silent> <c-space> <c-\><c-n>
" easier window navigation
vmap <silent> <c-l> <c-space><c-w>l
imap <silent> <c-l> <c-space><c-w>l
nmap <silent> <c-l> <c-space><c-w>l
smap <silent> <c-l> <c-space><c-w>l
tmap <silent> <c-l> <c-space><c-w>l
vmap <silent> <c-h> <c-space><c-w>h
imap <silent> <c-h> <c-space><c-w>h
nmap <silent> <c-h> <c-space><c-w>h
smap <silent> <c-h> <c-space><c-w>h
tmap <silent> <c-h> <c-space><c-w>h
vmap <silent> <c-j> <c-space><c-w>j
imap <silent> <c-j> <c-space><c-w>j
nmap <silent> <c-j> <c-space><c-w>j
smap <silent> <c-j> <c-space><c-w>j
tmap <silent> <c-j> <c-space><c-w>j
vmap <silent> <c-k> <c-space><c-w>k
imap <silent> <c-k> <c-space><c-w>k
nmap <silent> <c-k> <c-space><c-w>k
smap <silent> <c-k> <c-space><c-w>k
tmap <silent> <c-k> <c-space><c-w>k
"{{{ Mappings
" quickly switch back to previous buffer
nnoremap <leader><space> <cmd>b#<cr>
" easier way to clear search highlighting
nnoremap <leader>n <cmd>noh<cr>
" delete a buffer without deleting the window
nnoremap <leader>q <cmd>Bdelete<cr>
" Open the file explorer in the current window
nnoremap <leader>t <cmd>Fern . -reveal=%<cr>
" Quickly splitting windows
nnoremap <leader>v <C-w>v
" Searching with fzf
nnoremap <leader>f <cmd>Files<cr>
" nnoremap <leader>f <cmd>lua require'telescope.builtin'.find_files{}<cr>
nnoremap <leader>b <cmd>Buffers<cr>
nnoremap <leader>g <cmd>Rg<cr>
nnoremap <leader>c <cmd>Commands<cr>
nnoremap <leader>h <cmd>Helptags<cr>
nnoremap <leader>m <cmd>Marks<cr>
nnoremap <leader>j <cmd>lua require'telescope.builtin'.lsp_document_symbols{}<cr>
nnoremap <leader>J <cmd>lua require'telescope.builtin'.lsp_workspace_symbols{}<cr>
" Session management
nnoremap <leader>ss <cmd>Obsess<cr>
nnoremap <leader>sd <cmd>Obsess!<cr>
" Quick, section-based folding
nnoremap <leader>z zfa{
" use normal regex when searching in normal/visual mode
nnoremap / /\v
" search for highlighted text when entering search from visual mode
vnoremap / y/\V<c-r>=escape(@",'/\')<cr><cr>
" Trigger completion with <Tab>
inoremap <silent><expr> <tab>
\ pumvisible() ? "\<c-n>" :
\ <sid>check_back_space() ? "\<tab>" :
\ completion#trigger_completion()
inoremap <silent><expr> <s-tab>
\ pumvisible() ? "\<c-p>" :
\ <sid>check_back_space() ? "\<s-tab>" :
\ completion#trigger_completion()
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
lua require 'lsp'
lua require 'options'
lua require 'mappings'
lua require 'treesitter'
" lua require 'snippets-config'
lua require 'statusline'
local cmd = vim.cmd -- to execute Vim commands e.g. cmd('pwd')
local fn = vim.fn -- to call Vim functions e.g. fn.bufnr()
local g = vim.g -- a table to access global variables
local lspconfig = require('lspconfig')
local buf_set_keymap = vim.api.nvim_buf_set_keymap
-- disable snippets by default
local capabilities = {
textDocument = {
completion = {
completionItem = {
snippetSupport = false
}
}
}
}
local on_attach = function(client, bufnr)
require('completion').on_attach(client)
local opts = { noremap=true, silent=true }
-- there are several goto def/impl/decl actions. this first one is my favorite
buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
-- the traditional mapping
buf_set_keymap(bufnr, 'n', '<c-]>', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
buf_set_keymap(bufnr, 'n', '<c-k>', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
buf_set_keymap(bufnr, 'n', '1gD', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
buf_set_keymap(bufnr, 'n', 'g0', '<cmd>lua vim.lsp.buf.document_symbol()<cr>', opts)
buf_set_keymap(bufnr, 'n', 'gW', '<cmd>lua vim.lsp.buf.workspace_symbol()<cr>', opts)
buf_set_keymap(bufnr, 'n', '<localleader>r', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
buf_set_keymap(bufnr, 'n', '<localleader>d', '<cmd>lua vim.lsp.util.show_line_diagnostics()<cr>', opts)
-- configuration for diagnostics
buf_set_keymap(bufnr, 'n', 'g[', '<cmd>lua vim.lsp.diagnostic.goto_prev()<cr>', opts)
buf_set_keymap(bufnr, 'n', 'g]', '<cmd>lua vim.lsp.diagnostic.goto_next()<cr>', opts)
-- TODO: add a mapping for goto implementation
-- buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
end
local servers = {
["rust_analyzer"] = {},
["pyls"] = {},
["clangd"] = {},
["gopls"] = {},
["tsserver"] = {},
["texlab"] = {},
["bashls"] = {},
["html"] = {},
["cssls"] = {}
}
for lsp, server_tweaks in pairs(servers) do
-- these settings are shared among all the servers
local server_defaults = {
capabilities = capabilities,
on_attach = on_attach
}
local server_setup = vim.tbl_extend('force', server_defaults, server_tweaks)
lspconfig[lsp].setup(server_setup)
end
local o = vim.o
local wo = vim.wo
local bo = vim.bo
local function map_modes(modes, shortcut, action, options)
local default_options = {
silent = true,
noremap = true
}
options = options or {}
options = vim.tbl_extend('force', default_options, options)
for _, mode in ipairs(modes) do
vim.api.nvim_set_keymap(mode, shortcut, action, options)
end
end
local function nmap(shortcut, action, options)
map_modes({'n'}, shortcut, action, options)
end
-- more accessible shortcut for escape
-- also more consistent when using the terminal
map_modes({'i', 'v', 'n', 's'}, '<c-space>', '<esc>')
map_modes({'t'}, '<c-space>', '<c-\\><c-n>')
-- easier window navigation
local nav_modes = {'i', 'v', 'n', 's', 't'}
local remap = {noremap = false}
map_modes(nav_modes, '<c-l>', '<c-space><c-w>l', remap)
map_modes(nav_modes, '<c-h>', '<c-space><c-w>h', remap)
map_modes(nav_modes, '<c-j>', '<c-space><c-w>j', remap)
map_modes(nav_modes, '<c-k>', '<c-space><c-w>k', remap)
-- easier tab navigation
map_modes(nav_modes, '<a-l>', '<c-space><cmd>tabn<cr>', remap)
map_modes(nav_modes, '<a-h>', '<c-space><cmd>tabp<cr>', remap)
-- quickly switch back to previous buffer
nmap('<leader><space>', '<cmd>b#<cr>')
-- easier way to clear search highlighting
nmap('<leader>n', '<cmd>noh<cr>')
-- delete a buffer without deleting the window
nmap('<leader>q', '<cmd>BufferClose<cr>')
-- Open the file explorer in the current window
nmap('<leader>t', '<cmd>Fern . -reveal=%<cr>')
-- Quickly splitting windows
nmap('<leader>v', '<C-w>v')
-- Searching with fzf
nmap('<leader>f', '<cmd>Files<cr>')
-- nmap('<leader>f', '<cmd>lua require\'telescope.builtin\'.find_files{}<cr>')
nmap('<leader>b', '<cmd>Buffers<cr>')
nmap('<leader>g', '<cmd>Rg<cr>')
nmap('<leader>c', '<cmd>Commands<cr>')
nmap('<leader>h', '<cmd>Helptags<cr>')
nmap('<leader>m', '<cmd>Marks<cr>')
nmap('<leader>j', '<cmd>lua require\'telescope.builtin\'.lsp_document_symbols{}<cr>')
nmap('<leader>J', '<cmd>lua require\'telescope.builtin\'.lsp_workspace_symbols{}<cr>')
-- Session management
nmap('<leader>ss', '<cmd>Obsess<cr>')
nmap('<leader>sd', '<cmd>Obsess!<cr>')
-- Convenient terminal window
nmap('<leader>;', '<cmd>FloatermToggle<cr>')
local o = vim.o
local wo = vim.wo
local bo = vim.bo
-- no automatic word-wrapping
bo.tw = 0
-- only redraw when necessary (makes macros run faster)
o.lazyredraw = true
-- show whitespace
wo.list = true
o.listchars = 'tab:→ ,space:·,nbsp:␣,trail:•,eol:¶,precedes:«,extends:»'
-- show line numbers relative to the current position
wo.number = true
wo.relativenumber = true
-- Show when I'm in an open fold
wo.foldcolumn = '1'
-- Automatically close folds when leaving them
o.foldclose = 'all'
-- Keep the cursor 10 lines from the top/bottom of the screen
o.scrolloff = 10
-- Automatically hit enter for me
bo.textwidth=80
-- Required for operations modifying multiple buffers like rename.
o.hidden = true
-- Highlight the line your cursor is on
wo.cursorline = true
-- Prevent the window from resizing due to the gitgutter being added
wo.signcolumn = 'yes'
-- ignore casing when searching w/ all lower-case letters
o.ignorecase = true
o.smartcase = true
-- showmode hides the echodoc function signatures,
-- and airline already shows the mode
o.showmode = false
-- persist undo history between sessions
bo.undofile = true
local manager = require 'snippets'
local guard = [[#ifndef ${1:UNIT_NAME}_H_
#define $1_H_
#endif // $1_H_]]
local U = require 'snippets.utils'
local snippets = {
_global = {
mpl2 = U.force_comment [[This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.]],
copyright = U.force_comment [[Copyright (C) Ian Boll ${=os.date("%Y")}]]
},
c = {
guard = guard
},
cpp = {
guard = guard
}
}
manager.use_suggested_mappings()
manager.snippets = snippets
local lualine = require 'lualine'
local options = lualine.options
options.theme = 'onedark'
options.section_separators = nil
options.component_separators = nil
options.icons_enabled = false
lualine.extensions = {'fzf'}
lualine.status()
local o = vim.o
local wo = vim.wo
local bo = vim.bo
-- not using expr until I can get it to only fold functions
wo.foldmethod = 'manual'
vim.cmd 'set foldexpr=nvim_treesitter#foldexpr()'
require'nvim-treesitter.configs'.setup {
ensure_installed = 'maintained',
highlight = {
enable = true,
disable = {'rust'} -- list of languages to disable
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = 's',
node_incremental = 'sn',
scope_incremental = 'ss',
node_decremental = 'sd'
}
},
indent = {
enable = true,
disable = {'rust'}
},
playground = {
enable = true,
disable = {},
updatetime = 25,
persist_queries = false
}
}