I learned once again that true color schemes don't work in macOS's Terminal.app. I also learned that the default color scheme in neovim is very plain and doesn't provide a lot of variation for treesitter syntax elements. So, choose a different built-in color scheme as the default. I also learned about the ColorScheme autocmd event, which is fired after a color scheme is applied. Convert the (janky) reloadColorscheme function to a set of autocommands that trigger based on the color scheme name. Along the way, add some explicit configuration for treesitter: enable highlighting, indentation, and make sure some of my common languages have plugins installed. Also link the "objcpp" filetype to both "objc" and "cpp" treesitter plugins. Lastly, make some updates to the git gutter color configuration. Create some autocommands that are applied after the plugin is loaded. For the gutter, use color 233 from the 256 color palette, which is a very dark gray.
105 lines
2.6 KiB
Lua
105 lines
2.6 KiB
Lua
-- Eryn Wells <eryn@erynwells.me>
|
|
|
|
require 'os'
|
|
|
|
function gitTopLevelDirectory()
|
|
local handle = io.popen('git rev-parse --show-toplevel')
|
|
if handle == nil then
|
|
return nil
|
|
end
|
|
|
|
local gitRepoTopLevelDirectoryPath = vim.fn.trim(handle:read('*a'))
|
|
handle:close()
|
|
|
|
return gitRepoTopLevelDirectoryPath
|
|
end
|
|
|
|
local function _addPathToRuntimePath(path, options)
|
|
if string.len(path) == 0 then
|
|
return
|
|
end
|
|
|
|
if vim.fn.isdirectory(path) == 1 then
|
|
if options.prepend then
|
|
vim.opt.runtimepath:prepend(path)
|
|
else
|
|
vim.opt.runtimepath:append(path)
|
|
end
|
|
end
|
|
end
|
|
|
|
function addGitTopLevelDirectoryToRuntimePath()
|
|
local gitTopLevelPath = gitTopLevelDirectory()
|
|
if gitTopLevelPath == nil or string.len(gitTopLevelPath) == 0 then
|
|
return
|
|
end
|
|
|
|
local repoVimPath = gitTopLevelPath .. "/.vim"
|
|
if vim.fn.isdirectory(repoVimPath) == 1 then
|
|
vim.opt.runtimepath:prepend(repoVimPath)
|
|
end
|
|
local repoNvimPath = gitTopLevelPath .. "/.nvim"
|
|
if vim.fn.isdirectory(repoNvimPath) == 1 then
|
|
vim.opt.runtimepath:prepend(repoNvimPath)
|
|
end
|
|
|
|
local repoVimAfterPath = gitTopLevelPath .. "/.nvim/after"
|
|
if vim.fn.isdirectory(repoVimAfterPath) == 1 then
|
|
vim.opt.runtimepath:append(repoVimAfterPath)
|
|
end
|
|
local repoNvimAfterPath = gitTopLevelPath .. "/.vim/after"
|
|
if vim.fn.isdirectory(repoNvimAfterPath) == 1 then
|
|
vim.opt.runtimepath:append(repoNvimAfterPath)
|
|
end
|
|
end
|
|
|
|
addGitTopLevelDirectoryToRuntimePath()
|
|
|
|
vim.cmd [[
|
|
source ~/.vimrc.common
|
|
source ~/.vim/plugins.vim
|
|
]]
|
|
|
|
require 'autocommands'
|
|
require 'colors'
|
|
require 'configuration'
|
|
require 'diagnostics'
|
|
require 'treesitter'
|
|
require 'lsp'
|
|
|
|
local keys = require 'keys'
|
|
keys.init_key_opts()
|
|
keys.init_window_key_mappings()
|
|
keys.init_diagnostic_key_mappings()
|
|
|
|
local gui = require 'gui'
|
|
gui.init()
|
|
|
|
function ErynEnsureMetadataDirectoriesExist()
|
|
local paths = {
|
|
vim.opt.backupdir:get(),
|
|
vim.opt.directory:get(),
|
|
vim.opt.undodir:get(),
|
|
}
|
|
|
|
local function makeDirectory(path)
|
|
os.execute("mkdir -p " .. path)
|
|
end
|
|
|
|
for _, opt in ipairs(paths) do
|
|
for _, value in ipairs(opt) do
|
|
if string.find(value, "//$") then
|
|
makeDirectory(value)
|
|
end
|
|
end
|
|
end
|
|
|
|
-- The shadafile option is a single option but get() returns a table, so
|
|
-- iterate it just to be safe.
|
|
for _, opt in ipairs(vim.opt.shadafile:get()) do
|
|
local shadaDirectory = vim.fs.dirname(opt)
|
|
makeDirectory(shadaDirectory)
|
|
end
|
|
end
|
|
|
|
ErynEnsureMetadataDirectoriesExist()
|