Initial nvim configuration

This commit is contained in:
~erin 2023-02-19 10:59:52 -05:00
commit cd7a1ff664
12 changed files with 563 additions and 0 deletions

35
init.lua Normal file
View File

@ -0,0 +1,35 @@
-- display
vim.opt.showmode = true -- show editing mode
vim.opt.title = true -- custom title
vim.opt.number = true -- display line numbers
vim.opt.lazyredraw = true
-- spellcheck
vim.opt.spelllang = en,fr,de
vim.opt.spellsuggest = best,9
-- case-insensitive search except when using capitals
vim.opt.ignorecase = true
vim.opt.smartcase = true
-- miscellaneous
vim.opt.confirm = true -- ask to save before failed command
vim.opt.cmdheight = 2 -- set command window height to 2 lines
-- indentation
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
-- automatically switch buffer name when target file isn't read/write-able
vim.g.suda_smart_edit = 1
require("latex")
require("plugins")
require("plugins/statusline")
require("plugins/treesitter")
require("plugins/catppuccin")
require("plugins/lsp")
require("plugins/black")
require("plugins/angry-reviewer")
require("plugins/chad")
require("plugins/FRC")

4
lua/latex.lua Normal file
View File

@ -0,0 +1,4 @@
vim.g.tex_flavor = 'latex'
vim.g.tex_conceal = ''
vim.g.vimtex_fold_manual = 1
vim.g.vimtex_compiler_progname = 'tectonic'

74
lua/plugins.lua Normal file
View File

@ -0,0 +1,74 @@
-- automatically compile new plugins
vim.cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerCompile
augroup end
]])
return require('packer').startup(function(use)
-- Packer can manage itself
use 'wbthomason/packer.nvim'
-- Catppuccin theme
use { "catppuccin/nvim", as = "catppuccin" }
-- Statusline
use {
'nvim-lualine/lualine.nvim',
requires = { 'kyazdani42/nvim-web-devicons', opt = true }
}
-- Treesitter
use {
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate'
}
-- Fuzzy finder
use {
'junegunn/fzf',
run = 'fzf#install()'
}
use 'junegunn/fzf.vim'
-- Easy commenting
use 'tpope/vim-commentary'
-- git decorations
use {
'lewis6991/gitsigns.nvim',
config = function()
require('gitsigns').setup()
end
}
-- File explorer
use {
'ms-jpq/chadtree', branch = 'chad',
run = '!python3 -m chadtree deps'
}
-- LSP
use 'neovim/nvim-lspconfig'
use 'simrat39/rust-tools.nvim'
use 'hrsh7th/nvim-cmp'
use 'hrsh7th/cmp-nvim-lsp'
use 'hrsh7th/cmp-vsnip'
use 'hrsh7th/cmp-path'
use 'hrsh7th/cmp-buffer'
use 'hrsh7th/vim-vsnip'
use 'alaviss/nim.nvim'
-- Angry reviewer
use 'anufrievroman/vim-angry-reviewer'
-- Sudo
use 'lambdalisue/suda.vim'
-- git
use 'tpope/vim-fugitive'
end)

3
lua/plugins/FRC.lua Normal file
View File

@ -0,0 +1,3 @@
vim.api.nvim_create_user_command('FRCbuild', '!gradle build', {})
vim.api.nvim_create_user_command('FRCdeploy', '!gradle deploy', {})
vim.api.nvim_create_user_command('FRCconfig', ':LspStop', {})

View File

@ -0,0 +1,2 @@
vim.g.AngryReviewerEnglish = 'american'
vim.keymap.set('n', 'ar', '<cmd>AngryReviewer<cr>')

8
lua/plugins/black.lua Normal file
View File

@ -0,0 +1,8 @@
-- run black formatter on save
local black_on_save = vim.api.nvim_create_augroup('black_on_save', {
clear = true })
vim.api.nvim_create_autocmd('BufWritePost', {
pattern = '*.py',
group = 'black_on_save',
command = 'silent! !black -q <afile>',
})

View File

@ -0,0 +1,46 @@
require("catppuccin").setup({
flavour = "mocha", -- latte, frappe, macchiato, mocha
background = { -- :h background
light = "latte",
dark = "mocha",
},
transparent_background = true,
show_end_of_buffer = false, -- show the '~' characters after the end of buffers
term_colors = true,
dim_inactive = {
enabled = false,
shade = "dark",
percentage = 0.15,
},
no_italic = false, -- Force no italic
no_bold = false, -- Force no bold
styles = {
comments = { "italic" },
conditionals = { "italic" },
loops = {},
functions = {},
keywords = {},
strings = {},
variables = {},
numbers = {},
booleans = {},
properties = {},
types = {},
operators = {},
},
color_overrides = {},
custom_highlights = {},
integrations = {
cmp = true,
treesitter = true,
gitsigns = true,
nvimtree = true,
telescope = true,
notify = false,
mini = false,
-- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations)
},
})
-- setup must be called before loading
vim.cmd.colorscheme "catppuccin"

1
lua/plugins/chad.lua Normal file
View File

@ -0,0 +1 @@
vim.keymap.set('n', 'f', '<cmd>CHADopen<cr>')

122
lua/plugins/lsp.lua Normal file
View File

@ -0,0 +1,122 @@
vim.opt.completeopt = "menu,menuone,noinsert"
local nvim_lsp = require'lspconfig'
local opts = {
tools = { -- rust-tools options
autoSetHints = true,
inlay_hints = {
show_parameter_hints = false,
parameter_hints_prefix = "",
other_hints_prefix = "",
},
},
-- all the opts to send to nvim-lspconfig
-- these override the defaults set by rust-tools.nvim
-- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer
server = {
-- on_attach is a callback called when the language server attachs to the buffer
-- on_attach = on_attach,
settings = {
-- to enable rust-analyzer settings visit:
-- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc
["rust-analyzer"] = {
-- enable clippy on save
checkOnSave = {
command = "clippy"
},
}
}
},
}
require('rust-tools').setup(opts)
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { 'pylsp', 'gdscript'}
for _, lsp in pairs(servers) do
require('lspconfig')[lsp].setup {
on_attach = on_attach,
flags = {
-- This will be the default in neovim 0.7+
debounce_text_changes = 150,
}
}
end
-- Java LSP (WPILib broken :/)
require'lspconfig'.java_language_server.setup{ cmd = { "/home/erin/src/java-language-server/dist/lang_server_linux.sh" } }
-- Setup Completion
-- See https://github.com/hrsh7th/nvim-cmp#basic-configuration
local cmp = require'cmp'
cmp.setup({
-- Enable LSP snippets
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
-- Add tab support
['<S-Tab>'] = cmp.mapping.select_prev_item(),
['<Tab>'] = cmp.mapping.select_next_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
})
},
-- Installed sources
sources = {
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
{ name = 'path' },
{ name = 'buffer' },
},
})
local api = vim.api
-- set updatetime for CursorHold
-- 300ms of no cursor movement to trigger CursorHold
vim.opt.updatetime = 300
-- show diagnostic popup on cursor hold
api.nvim_create_autocmd("CursorHold", {
command = "lua vim.diagnostic.open_float(nil, { focusable = false })",
})
-- fixed column for the diagnostics to appear in
vim.opt.signcolumn = "yes"
-- auto-format *.rs (rust) files prior to saving them
api.nvim_create_autocmd("BufWritePre", {
pattern = "*.rs",
command = "lua vim.lsp.buf.formatting_sync(nil, 1000)",
})
-- Code navigation shortcutst
vim.keymap.set('n', 'K', function()
return vim.lsp.buf.hover()
end, { silent = true })
vim.keymap.set('n', 'gr', function()
return vim.lsp.buf.references()
end, { silent = true, buffer = true })
vim.keymap.set('n', 'gd', function()
return vim.lsp.buf.definition()
end, { silent = true, buffer = true })
vim.keymap.set('n', 'ga', function()
return vim.lsp.buf.code_action()
end, { silent = true, buffer = true })
vim.keymap.set('n', '1gD', function()
return vim.lsp.buf.type_definition()
end, { silent = true, buffer = true })

View File

@ -0,0 +1,40 @@
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = ''},
section_separators = { left = '', right = ''},
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = false,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
}
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {'filename'},
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {}
}

View File

@ -0,0 +1,18 @@
require'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all" (the four listed parsers should always be installed)
ensure_installed = { "c", "cpp", "lua", "vim", "help", "bash", "cmake", "make", "html", "css", "scss", "javascript", "latex", "markdown", "toml", "json", "yaml", "dockerfile", "gitattributes", "git_rebase", "gitcommit", "gdscript", "http", "java", "php" },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = true,
-- Automatically install missing parsers when entering buffer
-- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
auto_install = true,
highlight = {
-- 'false' will disable the whole extension
enable = true,
additional_vim_regex_highlighting = false,
},
}

210
plugin/packer_compiled.lua Normal file
View File

@ -0,0 +1,210 @@
-- Automatically generated packer.nvim plugin loader code
if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then
vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"')
return
end
vim.api.nvim_command('packadd packer.nvim')
local no_errors, error_msg = pcall(function()
_G._packer = _G._packer or {}
_G._packer.inside_compile = true
local time
local profile_info
local should_profile = false
if should_profile then
local hrtime = vim.loop.hrtime
profile_info = {}
time = function(chunk, start)
if start then
profile_info[chunk] = hrtime()
else
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
end
end
else
time = function(chunk, start) end
end
local function save_profiles(threshold)
local sorted_times = {}
for chunk_name, time_taken in pairs(profile_info) do
sorted_times[#sorted_times + 1] = {chunk_name, time_taken}
end
table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
local results = {}
for i, elem in ipairs(sorted_times) do
if not threshold or threshold and elem[2] > threshold then
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
end
end
if threshold then
table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)')
end
_G._packer.profile_output = results
end
time([[Luarocks path setup]], true)
local package_path_str = "/home/erin/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/home/erin/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/home/erin/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/home/erin/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/home/erin/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so"
if not string.find(package.path, package_path_str, 1, true) then
package.path = package.path .. ';' .. package_path_str
end
if not string.find(package.cpath, install_cpath_pattern, 1, true) then
package.cpath = package.cpath .. ';' .. install_cpath_pattern
end
time([[Luarocks path setup]], false)
time([[try_loadstring definition]], true)
local function try_loadstring(s, component, name)
local success, result = pcall(loadstring(s), name, _G.packer_plugins[name])
if not success then
vim.schedule(function()
vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
end)
end
return result
end
time([[try_loadstring definition]], false)
time([[Defining packer_plugins]], true)
_G.packer_plugins = {
catppuccin = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/catppuccin",
url = "https://github.com/catppuccin/nvim"
},
chadtree = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/chadtree",
url = "https://github.com/ms-jpq/chadtree"
},
["cmp-buffer"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/cmp-buffer",
url = "https://github.com/hrsh7th/cmp-buffer"
},
["cmp-nvim-lsp"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp",
url = "https://github.com/hrsh7th/cmp-nvim-lsp"
},
["cmp-path"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/cmp-path",
url = "https://github.com/hrsh7th/cmp-path"
},
["cmp-vsnip"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/cmp-vsnip",
url = "https://github.com/hrsh7th/cmp-vsnip"
},
fzf = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/fzf",
url = "https://github.com/junegunn/fzf"
},
["fzf.vim"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/fzf.vim",
url = "https://github.com/junegunn/fzf.vim"
},
["gitsigns.nvim"] = {
config = { "\27LJ\2\0026\0\0\2\0\3\0\0066\0\0\0'\1\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\rgitsigns\frequire\0" },
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/gitsigns.nvim",
url = "https://github.com/lewis6991/gitsigns.nvim"
},
["lualine.nvim"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/lualine.nvim",
url = "https://github.com/nvim-lualine/lualine.nvim"
},
["nim.nvim"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/nim.nvim",
url = "https://github.com/alaviss/nim.nvim"
},
["nvim-cmp"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/nvim-cmp",
url = "https://github.com/hrsh7th/nvim-cmp"
},
["nvim-lspconfig"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
url = "https://github.com/neovim/nvim-lspconfig"
},
["nvim-treesitter"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/nvim-treesitter",
url = "https://github.com/nvim-treesitter/nvim-treesitter"
},
["nvim-web-devicons"] = {
loaded = false,
needs_bufread = false,
path = "/home/erin/.local/share/nvim/site/pack/packer/opt/nvim-web-devicons",
url = "https://github.com/kyazdani42/nvim-web-devicons"
},
["packer.nvim"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/packer.nvim",
url = "https://github.com/wbthomason/packer.nvim"
},
["rust-tools.nvim"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/rust-tools.nvim",
url = "https://github.com/simrat39/rust-tools.nvim"
},
["suda.vim"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/suda.vim",
url = "https://github.com/lambdalisue/suda.vim"
},
["vim-angry-reviewer"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/vim-angry-reviewer",
url = "https://github.com/anufrievroman/vim-angry-reviewer"
},
["vim-commentary"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/vim-commentary",
url = "https://github.com/tpope/vim-commentary"
},
["vim-fugitive"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/vim-fugitive",
url = "https://github.com/tpope/vim-fugitive"
},
["vim-vsnip"] = {
loaded = true,
path = "/home/erin/.local/share/nvim/site/pack/packer/start/vim-vsnip",
url = "https://github.com/hrsh7th/vim-vsnip"
}
}
time([[Defining packer_plugins]], false)
-- Config for: gitsigns.nvim
time([[Config for gitsigns.nvim]], true)
try_loadstring("\27LJ\2\0026\0\0\2\0\3\0\0066\0\0\0'\1\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\rgitsigns\frequire\0", "config", "gitsigns.nvim")
time([[Config for gitsigns.nvim]], false)
_G._packer.inside_compile = false
if _G._packer.needs_bufread == true then
vim.cmd("doautocmd BufRead")
end
_G._packer.needs_bufread = false
if should_profile then save_profiles() end
end)
if not no_errors then
error_msg = error_msg:gsub('"', '\\"')
vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
end