[nvim] Move neovim config to /nvim
This commit is contained in:
parent
e45c1694af
commit
5b567ad2ad
28 changed files with 0 additions and 0 deletions
22
nvim/UltiSnips/lua.snippets
Normal file
22
nvim/UltiSnips/lua.snippets
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# lua.snippets
|
||||
# vim: set ts=8 sw=8 sts=8 noet list:
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
|
||||
snippet pd
|
||||
local pd <const> = playdate
|
||||
endsnippet
|
||||
|
||||
snippet gfx
|
||||
local gfx <const> = playdate.graphics
|
||||
endsnippet
|
||||
|
||||
snippet sprite
|
||||
class("${1:Sprite}").extends(gfx.sprite)
|
||||
|
||||
function $1:init()
|
||||
end
|
||||
|
||||
function $1:update()
|
||||
end
|
||||
endsnippet
|
||||
49
nvim/UltiSnips/python.snippets
Normal file
49
nvim/UltiSnips/python.snippets
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# python.snippets
|
||||
# vim: set ts=8 sw=8 sts=8 noet list:
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
snippet parse_args
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
# TODO: Configure arguments here.
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
endsnippet
|
||||
|
||||
snippet ifmain
|
||||
def main(argv):
|
||||
${1:pass}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
sys.exit(main(sys.argv))
|
||||
endsnippet
|
||||
|
||||
snippet script
|
||||
#!/usr/bin/env python3
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
'''
|
||||
New script.
|
||||
'''
|
||||
|
||||
import argparse
|
||||
|
||||
|
||||
def parse_args(argv, *a, **kw):
|
||||
parser = argparse.ArgumentParser(*a, **kw)
|
||||
# TODO: Configure arguments here.
|
||||
args = parser.parse_args(argv)
|
||||
return args
|
||||
|
||||
|
||||
def main(argv):
|
||||
args = parse_args(argv[1:], prog=argv[0])
|
||||
${1:# TODO}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
sys.exit(main(sys.argv))
|
||||
endsnippet
|
||||
38
nvim/UltiSnips/rust.snippets
Normal file
38
nvim/UltiSnips/rust.snippets
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# rust.snippets
|
||||
# vim: set ts=8 sw=8 sts=8 noet list:
|
||||
# Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
snippet nnapp
|
||||
// Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
use nannou::prelude::*;
|
||||
|
||||
struct Model {
|
||||
_window: window::Id,
|
||||
}
|
||||
|
||||
impl Model {
|
||||
fn new(app: &App) -> Self {
|
||||
let window = app.new_window().view(view).build().unwrap();
|
||||
Self {
|
||||
_window: window,
|
||||
}
|
||||
}
|
||||
|
||||
fn update(app: &App, model: &mut Model, update: Update) {
|
||||
model.update(app, update)
|
||||
}
|
||||
|
||||
fn update(&mut self, app: &App, update: Update) {
|
||||
// TODO: Update the model here.
|
||||
}
|
||||
}
|
||||
|
||||
fn view(app: &App, model: &Model, frame: Frame) {
|
||||
// TODO: Draw the view here.
|
||||
}
|
||||
|
||||
fn main() {
|
||||
nannou::app(Model::new).update(update).run();
|
||||
}
|
||||
endsnippet
|
||||
4
nvim/after/ftplugin/css.lua
Normal file
4
nvim/after/ftplugin/css.lua
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
4
nvim/after/ftplugin/gitcommit.vim
Normal file
4
nvim/after/ftplugin/gitcommit.vim
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
" Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
" The default text width for git commit messages is 72 characters, which is just too dang small.
|
||||
setlocal textwidth=80
|
||||
4
nvim/after/ftplugin/gohtmltmpl.lua
Normal file
4
nvim/after/ftplugin/gohtmltmpl.lua
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
vim.bo.shiftwidth = 2
|
||||
vim.bo.softtabstop = 2
|
||||
4
nvim/after/ftplugin/html.lua
Normal file
4
nvim/after/ftplugin/html.lua
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
18
nvim/after/ftplugin/lua.lua
Normal file
18
nvim/after/ftplugin/lua.lua
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
local expand = vim.fn.expand
|
||||
local resolve = vim.fn.resolve
|
||||
local stdpath = vim.fn.stdpath
|
||||
|
||||
-- My dotfiles are usually symlinks. Resolve them so the path comparison makes sense.
|
||||
local configPath = resolve(stdpath("config"))
|
||||
local fullPath = resolve(expand("%:p"))
|
||||
if string.find(fullPath, configPath) == 1 then
|
||||
vim.opt_local.path = {
|
||||
".",
|
||||
"",
|
||||
configPath .. "/**",
|
||||
}
|
||||
|
||||
vim.opt_local.suffixesadd:append(".lua")
|
||||
end
|
||||
2
nvim/after/ftplugin/python.lua
Normal file
2
nvim/after/ftplugin/python.lua
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
3
nvim/after/ftplugin/rust.lua
Normal file
3
nvim/after/ftplugin/rust.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
vim.opt.foldmethod = 'syntax'
|
||||
1
nvim/after/ftplugin/text.vim
Normal file
1
nvim/after/ftplugin/text.vim
Normal file
|
|
@ -0,0 +1 @@
|
|||
abbr hawaii Hawai‘i
|
||||
15
nvim/after/ftplugin/zsh.lua
Normal file
15
nvim/after/ftplugin/zsh.lua
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
local zshFPath = vim.env.FPATH
|
||||
if zshFPath then
|
||||
local paths = vim.split(zshFPath, ":")
|
||||
vim.bo.path = ".," .. table.concat(paths, ",") .. ",,"
|
||||
else
|
||||
local defaultFPath = {
|
||||
"~/.dotfiles/zsh/func/**",
|
||||
"~/.zsh/func/**",
|
||||
"/usr/local/share/zsh/site-functions",
|
||||
"/usr/share/zsh/site-functions"
|
||||
}
|
||||
vim.bo.path = ".," .. table.concat(defaultFPath) .. ",,"
|
||||
end
|
||||
27
nvim/after/plugin/gitgutter.lua
Normal file
27
nvim/after/plugin/gitgutter.lua
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
-- Ensure there's always a gutter column so there's no stutter when changes cause it to appear.
|
||||
vim.wo.signcolumn = "yes"
|
||||
|
||||
local gitgutter_colorscheme_group = vim.api.nvim_create_augroup("GitGutterColorSchemeOverrides", { clear = true })
|
||||
|
||||
local function update_gitgutter_colors()
|
||||
vim.cmd [[
|
||||
hi! SignColumn ctermbg=233
|
||||
hi! GitGutterAdd ctermbg=233
|
||||
hi! GitGutterRemove ctermbg=233
|
||||
hi! GitGutterChange ctermbg=233
|
||||
hi! GitGutterChangeDelete ctermbg=233
|
||||
]]
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "GitGutter",
|
||||
callback = update_gitgutter_colors,
|
||||
group = gitgutter_colorscheme_group,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
callback = update_gitgutter_colors,
|
||||
group = gitgutter_colorscheme_group,
|
||||
})
|
||||
11
nvim/after/plugin/treesitter.lua
Normal file
11
nvim/after/plugin/treesitter.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
local treesitter_configs = require 'nvim-treesitter.configs'
|
||||
|
||||
treesitter_configs.setup {
|
||||
ensure_installed = { "lua", "vim" },
|
||||
sync_install = true,
|
||||
auto_install = true,
|
||||
hightlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
}
|
||||
7
nvim/after/syntax/css.vim
Normal file
7
nvim/after/syntax/css.vim
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
" css.vim
|
||||
" Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
syn match cssLogicalBoxProp contained "\<padding-\(block\|inline\)\=\(-\(start\|end\)\)\=\>"
|
||||
syn match cssLogicalBoxProp contained "\<margin-\(block\|inline\)\=\(-\(start\|end\)\)\=\>"
|
||||
|
||||
hi def link cssLogicalBoxProp cssProp
|
||||
7
nvim/ftdetect/gohtmltmpl.lua
Normal file
7
nvim/ftdetect/gohtmltmpl.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
-- Detect layout templates in Hugo projects
|
||||
vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, {
|
||||
pattern = {"*/layouts/*.html"},
|
||||
command = "setfiletype gohtmltmpl"
|
||||
})
|
||||
7
nvim/ftdetect/make.lua
Normal file
7
nvim/ftdetect/make.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
-- Filetype detection for Makefiles
|
||||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, {
|
||||
pattern = "*.make",
|
||||
command = "setfiletype make",
|
||||
})
|
||||
6
nvim/ftdetect/zsh.lua
Normal file
6
nvim/ftdetect/zsh.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, {
|
||||
pattern = {"*/zsh/*"},
|
||||
command = "setfiletype zsh",
|
||||
})
|
||||
91
nvim/init.lua
Normal file
91
nvim/init.lua
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
-- 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
|
||||
|
||||
-- Enable per-project (per-git repository) customization of (neo)vim by looking
|
||||
-- for .vim and .nvim directories in the root of the git repository.
|
||||
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
|
||||
|
||||
vim.cmd [[
|
||||
source ~/.vimrc.common
|
||||
source ~/.vim/plugins.vim
|
||||
]]
|
||||
|
||||
addGitTopLevelDirectoryToRuntimePath()
|
||||
|
||||
require 'autocommands'
|
||||
require 'colors'
|
||||
require 'configuration'
|
||||
require 'diagnostics'
|
||||
require 'treesitter'
|
||||
require 'lsp'
|
||||
|
||||
local keys = require 'keys'
|
||||
keys.init()
|
||||
|
||||
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()
|
||||
15
nvim/lua/autocommands.lua
Normal file
15
nvim/lua/autocommands.lua
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
vim.opt.updatetime = 300
|
||||
|
||||
-- Show diagnostic popup on cursor hover
|
||||
local diagnostic_float_group = vim.api.nvim_create_augroup("DiagnosticFloat", { clear = true })
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
callback = function()
|
||||
vim.diagnostic.open_float {
|
||||
border = "double",
|
||||
focusable = false,
|
||||
}
|
||||
end,
|
||||
group = diagnostic_float_group,
|
||||
})
|
||||
62
nvim/lua/colors.lua
Normal file
62
nvim/lua/colors.lua
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
-- Allow using GUI style colors (#RRGGBB hex codes) in color terminals if we
|
||||
-- know it can do it. This is required for most modern color themes. Apple's
|
||||
-- Terminal.app doesn't have True Color support though, so make sure it's
|
||||
-- off for that.
|
||||
vim.g.termguicolors = not vim.env.TERM_PROGRAM == "Apple_Terminal"
|
||||
|
||||
local colorscheme_group = vim.api.nvim_create_augroup("ColorSchemeOverrides", { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
callback = function()
|
||||
vim.cmd [[
|
||||
hi! ColorColumn cterm=NONE ctermbg=233
|
||||
hi! CursorColumn cterm=NONE ctermbg=233
|
||||
hi! CursorLine cterm=NONE ctermbg=233
|
||||
hi! CursorLineNr cterm=bold ctermfg=White ctermbg=233
|
||||
hi! LineNr ctermfg=DarkGray ctermbg=233
|
||||
]]
|
||||
end,
|
||||
group = colorscheme_group,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
pattern = "default",
|
||||
callback = function()
|
||||
vim.cmd [[ hi! NormalFloat ctermfg=8 ]]
|
||||
end,
|
||||
group = colorscheme_group,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
pattern = "dracula",
|
||||
callback = function()
|
||||
vim.cmd [[ highlight CursorLineNr guibg=#44475a ]]
|
||||
end,
|
||||
group = colorscheme_group,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
pattern = "witchhazel",
|
||||
callback = function()
|
||||
vim.cmd [[
|
||||
hi! default link LineNr CursorLineNr
|
||||
hi! default link CursorLineNr CursorLine
|
||||
]]
|
||||
end,
|
||||
group = colorscheme_group,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
pattern = "zaibatsu",
|
||||
callback = function()
|
||||
vim.cmd [[
|
||||
hi! Pmenu ctermbg=8
|
||||
hi! VertSplit ctermbg=8
|
||||
]]
|
||||
end,
|
||||
group = colorscheme_group,
|
||||
})
|
||||
|
||||
vim.cmd [[ color zaibatsu ]]
|
||||
123
nvim/lua/configuration.lua
Normal file
123
nvim/lua/configuration.lua
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
-- [[ Editor Configuration ]]
|
||||
local opt = vim.opt
|
||||
|
||||
-- Reread files when they change outside of neovim
|
||||
opt.autoread = true
|
||||
-- Don't write files before switching buffers
|
||||
opt.autowrite = false
|
||||
|
||||
opt.fileformats = {"unix", "dos", "mac"}
|
||||
|
||||
-- When creating splits, split on the right and below by default
|
||||
opt.splitright = true
|
||||
opt.splitbelow = true
|
||||
|
||||
-- Show line numbers
|
||||
opt.number = true
|
||||
opt.relativenumber = false
|
||||
|
||||
-- Start with ~all folds open.
|
||||
opt.foldlevel = 99
|
||||
|
||||
-- Customize the status bar a bit. Show the ruler, mode, and the command as the
|
||||
-- last line of the screen.
|
||||
opt.ruler = true
|
||||
opt.showmode = true
|
||||
opt.showcmd = true
|
||||
|
||||
-- Never beep!
|
||||
opt.visualbell = true
|
||||
opt.errorbells = false
|
||||
|
||||
-- Wrap text rather than letting it run offscreen
|
||||
opt.wrap = true
|
||||
opt.linebreak = true
|
||||
-- Wrap to 80 characters by default
|
||||
opt.textwidth = 80
|
||||
-- Mark columns 80, 90, and 120
|
||||
opt.colorcolumn = {80, 90, 120}
|
||||
|
||||
-- Briefly show the matching parenthesis or bracket when typing one of those
|
||||
-- characters.
|
||||
opt.showmatch = true
|
||||
|
||||
opt.formatoptions:append("n")
|
||||
|
||||
-- When in list mode (showing whitespace) use some nicer Unicode characters.
|
||||
opt.list = false
|
||||
opt.listchars = {
|
||||
tab = "▸ ",
|
||||
eol = "¬",
|
||||
trail = "・",
|
||||
extends = "→",
|
||||
nbsp = "・",
|
||||
}
|
||||
|
||||
-- Search options. Ignore case by default, but be case sensitive if the pattern
|
||||
-- contains a capital. Incrementally search, rather than waiting until you hit
|
||||
-- <Enter>. Search globally by default, rather than just on the current line.
|
||||
opt.ignorecase = true
|
||||
opt.smartcase = true
|
||||
opt.incsearch = true
|
||||
opt.gdefault = true
|
||||
|
||||
-- Prefer spaces to tabs. Indent tab characters 8 spaces, and soft indent 4
|
||||
-- spaces. Never write tabs if you can help it.
|
||||
opt.tabstop = 8
|
||||
opt.shiftwidth = 4
|
||||
opt.softtabstop = 4
|
||||
opt.shiftround = true
|
||||
opt.expandtab = true
|
||||
|
||||
-- Do some nice things when wrapping, joining, and copying.
|
||||
opt.joinspaces = false
|
||||
opt.autoindent = true
|
||||
opt.copyindent = true
|
||||
|
||||
-- Always show the last command you typed.
|
||||
opt.laststatus = 2
|
||||
|
||||
opt.background = "dark"
|
||||
|
||||
-- Save all this metadata while editing.
|
||||
opt.backup = true
|
||||
opt.undofile = true
|
||||
|
||||
local statedir = vim.fn.stdpath("state")
|
||||
opt.backupdir = {statedir .. "/backup//"}
|
||||
opt.directory = {statedir .. "/swap//", "."}
|
||||
opt.undodir = {statedir .. "/undo//"}
|
||||
|
||||
-- Fields to save in the Shada file. Parameters as follows: (see :help shada)
|
||||
-- % number of buffers to save and restore when no file argument is given
|
||||
-- ' maximum number of previously edited files for which marks are remembered
|
||||
-- h disable highlighted search patterns on start
|
||||
-- / omitted, so all search history is saved
|
||||
-- < maximum number of lines saved for each register
|
||||
-- : maximum number of lines of command history to save
|
||||
-- s shada entries over 100 KiB are skipped
|
||||
opt.shada = {"%100", "'1000", "h", "<1000", ":1000", "s100"}
|
||||
opt.shadafile = statedir .. "/shada/default.shada"
|
||||
|
||||
-- Scroll ahead of the point a bit in each direction
|
||||
opt.scrolloff = 3
|
||||
opt.sidescrolloff = 5
|
||||
|
||||
opt.wildmenu = true
|
||||
opt.wildmode = {"longest", "list"}
|
||||
opt.wildignore = {
|
||||
-- Build artifacts
|
||||
"*.o", "*.pyc", "*.lo", "*.class",
|
||||
-- Swap files
|
||||
"*~",
|
||||
-- Non-text things
|
||||
"*.db", "*.pdf", "*.jpg", "*.jpeg", "*.png", "*.gif",
|
||||
-- Auto-generated things
|
||||
".git", "env", "migrations"
|
||||
}
|
||||
|
||||
if vim.fn.has("mouse") then
|
||||
opt.mouse = "a"
|
||||
end
|
||||
15
nvim/lua/diagnostics.lua
Normal file
15
nvim/lua/diagnostics.lua
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
vim.diagnostic.config {
|
||||
virtual_text = false,
|
||||
signs = true,
|
||||
update_in_insert = true,
|
||||
underline = true,
|
||||
severity_sort = false,
|
||||
float = {
|
||||
border = 'rounded',
|
||||
source = 'always',
|
||||
header = '',
|
||||
prefix = '',
|
||||
},
|
||||
}
|
||||
25
nvim/lua/gui.lua
Normal file
25
nvim/lua/gui.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
local function _init_neovide()
|
||||
if not vim.g.neovide then
|
||||
return
|
||||
end
|
||||
|
||||
-- No use for these animations.
|
||||
vim.g.neovide_cursor_animation_length = 0
|
||||
vim.g.neovide_position_animation_length = 0
|
||||
vim.g.neovide_scroll_animation_length = 0
|
||||
|
||||
vim.g.neovide_input_macos_option_key_is_meta = "both"
|
||||
|
||||
vim.cmd [[ colorscheme lunaperche ]]
|
||||
end
|
||||
|
||||
function init_gui()
|
||||
vim.o.guifont = "Berkeley Mono,Input Mono Condensed,SF Mono,Courier New:h18"
|
||||
_init_neovide()
|
||||
end
|
||||
|
||||
return {
|
||||
init = init_gui,
|
||||
}
|
||||
113
nvim/lua/keys.lua
Normal file
113
nvim/lua/keys.lua
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
local map = vim.keymap.set
|
||||
|
||||
local function init_key_options()
|
||||
vim.g.mapleader = ","
|
||||
end
|
||||
|
||||
local function text_navigation_mappings()
|
||||
local options = { noremap = true }
|
||||
|
||||
-- Navigate by soft-wrapped lines using Alt/Option/Meta + jk
|
||||
map({'n', 'v'}, '<M-k>', 'gk', options)
|
||||
map({'n', 'v'}, '<M-j>', 'gj', options)
|
||||
end
|
||||
|
||||
local function clipboard_mappings()
|
||||
if not vim.fn.has('gui_running') then
|
||||
return
|
||||
end
|
||||
|
||||
local options = { noremap = true }
|
||||
|
||||
-- Copy to the system clipboard
|
||||
map('v', '<D-c>', '"+y', options)
|
||||
-- Cut to the system clipboard
|
||||
map('v', '<D-x>', '"+x', options)
|
||||
-- Paste from the system clipboard
|
||||
map({'i', 'v'}, '<D-v>', '"+p', options)
|
||||
end
|
||||
|
||||
local function window_key_mappings()
|
||||
local options = { silent = true }
|
||||
|
||||
-- Allow starting commands with ; instead of typing Shift-;. Save lots of keypresses!
|
||||
map('n', ';', ':')
|
||||
|
||||
map('n', '<C-h>', '<C-w>h', options)
|
||||
map('n', '<C-j>', '<C-w>j', options)
|
||||
map('n', '<C-k>', '<C-w>k', options)
|
||||
map('n', '<C-l>', '<C-w>l', options)
|
||||
|
||||
map('n', '<C-n>', ':bn<CR>', options)
|
||||
map('n', '<C-p>', ':bp<CR>', options)
|
||||
|
||||
map('n', '<leader><space>', function()
|
||||
vim.cmd [[ setlocal invhlsearch ]]
|
||||
end, options)
|
||||
end
|
||||
|
||||
--
|
||||
-- Language Server mappings
|
||||
--
|
||||
|
||||
local function diagnostic_mappings()
|
||||
local options = { noremap=true, silent=true }
|
||||
|
||||
-- Basic diagnostic mappings, these will navigate to or display diagnostics
|
||||
map('n', '<leader>d', vim.diagnostic.open_float, options)
|
||||
map('n', '[d', vim.diagnostic.goto_prev, options)
|
||||
map('n', ']d', vim.diagnostic.goto_next, options)
|
||||
map('n', '<leader>q', vim.diagnostic.setloclist, options)
|
||||
end
|
||||
|
||||
local function local_lsp_mappings(buffer_number)
|
||||
local options = { noremap=true, silent=true, buffer=buffer_number }
|
||||
|
||||
map('n', 'ga', vim.lsp.buf.code_action, options)
|
||||
map('n', 'gD', vim.lsp.buf.declaration, options)
|
||||
map('n', 'gd', vim.lsp.buf.definition, options)
|
||||
map('n', 'gk', vim.lsp.buf.hover, options)
|
||||
map('n', 'gi', vim.lsp.buf.implementation, options)
|
||||
map('n', 'gK', vim.lsp.buf.signature_help, options)
|
||||
map('n', '<C-i>', function()
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({}))
|
||||
end, options)
|
||||
map('n', '<leader>D', vim.lsp.buf.type_definition, options)
|
||||
map('n', '<leader>rn', vim.lsp.buf.rename, options)
|
||||
map('n', '<leader>ca', vim.lsp.buf.code_action, options)
|
||||
map('n', 'gr', vim.lsp.buf.references, options)
|
||||
|
||||
-- Replace <leader>W in .vimrc.common
|
||||
map('n', '<leader>W', function()
|
||||
vim.lsp.buf.format { async = true }
|
||||
end, options)
|
||||
end
|
||||
|
||||
local function telescope_mappings()
|
||||
local builtin = require('telescope.builtin')
|
||||
|
||||
map('n', '<leader>ff', builtin.find_files, { desc = 'Telescope find files' })
|
||||
map('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' })
|
||||
map('n', '<leader>fb', builtin.buffers, { desc = 'Telescope buffers' })
|
||||
map('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' })
|
||||
|
||||
if vim.fn.has('gui_running') then
|
||||
map('n', 'D-O', builtin.buffers, { desc = 'Open existing' })
|
||||
end
|
||||
end
|
||||
|
||||
local function init_all_global_keybindings()
|
||||
init_key_options()
|
||||
clipboard_mappings()
|
||||
window_key_mappings()
|
||||
text_navigation_mappings()
|
||||
diagnostic_mappings()
|
||||
telescope_mappings()
|
||||
end
|
||||
|
||||
return {
|
||||
init = init_all_global_keybindings,
|
||||
init_lsp_key_mappings = local_lsp_mappings,
|
||||
}
|
||||
142
nvim/lua/lsp.lua
Normal file
142
nvim/lua/lsp.lua
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
|
||||
local clangd_extensions = require 'clangd_extensions'
|
||||
local cmp = require 'cmp'
|
||||
local lspconfig = require 'lspconfig'
|
||||
|
||||
local keys = require 'keys'
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["UltiSnips#Anon"](args.body)
|
||||
end
|
||||
},
|
||||
window = {
|
||||
-- completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.abort(),
|
||||
-- Accept currently selected item. Set `select` to `false` to only
|
||||
-- confirm explicitly selected items.
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
}),
|
||||
sorting = {
|
||||
comparators = {
|
||||
cmp.config.compare.offset,
|
||||
cmp.config.compare.exact,
|
||||
-- cmp.config.compare.recently_used,
|
||||
clangd_extensions.cmp_scores,
|
||||
cmp.config.compare.kind,
|
||||
cmp.config.compare.sort_text,
|
||||
cmp.config.compare.length,
|
||||
cmp.config.compare.order,
|
||||
},
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "nvim_signature_help" },
|
||||
{ name = "ultisnips" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
})
|
||||
}
|
||||
|
||||
local cmp_capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
-- local protocol = require('vim.lsp.protocol')
|
||||
|
||||
local function on_attach(client, buffer_number)
|
||||
vim.api.nvim_buf_set_option(buffer_number, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
vim.wo.signcolumn = "yes"
|
||||
|
||||
keys.init_lsp_key_mappings(buffer_number)
|
||||
end
|
||||
|
||||
lspconfig.clangd.setup {
|
||||
on_attach = function(client, buffer_number)
|
||||
on_attach(client, buffer_number)
|
||||
|
||||
local clangd_inlay_hints = require('clangd_extensions.inlay_hints')
|
||||
clangd_inlay_hints.setup_autocmd()
|
||||
clangd_inlay_hints.set_inlay_hints()
|
||||
end,
|
||||
capabilities = cmp_capabilities,
|
||||
}
|
||||
|
||||
lspconfig.eslint.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = cmp_capabilities,
|
||||
}
|
||||
|
||||
lspconfig.ts_ls.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = cmp_capabilities,
|
||||
}
|
||||
|
||||
lspconfig.html.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = cmp_capabilities,
|
||||
}
|
||||
|
||||
lspconfig.lua_ls.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = cmp_capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
disable = { "lowercase-global" },
|
||||
},
|
||||
workspace = {
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
checkThirdParty = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
lspconfig.pyright.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = cmp_capabilities,
|
||||
}
|
||||
|
||||
lspconfig.rust_analyzer.setup {
|
||||
on_attach = function(client, buffer_number)
|
||||
on_attach(client, buffer_number)
|
||||
end,
|
||||
capabilities = cmp_capabilities,
|
||||
settings = {
|
||||
['rust-analyzer'] = {
|
||||
cargo = {
|
||||
buildScripts = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
checkOnSave = true,
|
||||
check = {
|
||||
command = 'clippy',
|
||||
extraArgs = {
|
||||
"--",
|
||||
"--no-deps",
|
||||
"-Dclippy::correctness",
|
||||
"-Dclippy::complexity",
|
||||
"-Wclippy::perf",
|
||||
"-Wclippy::pedantic",
|
||||
},
|
||||
},
|
||||
imports = {
|
||||
granularity = {
|
||||
group = "crate",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
16
nvim/lua/treesitter.lua
Normal file
16
nvim/lua/treesitter.lua
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
-- Treesitter configuration
|
||||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
local treesitter = require 'nvim-treesitter.configs'
|
||||
|
||||
-- For some reason the Lua linter complains about missing fields here even
|
||||
-- though they're not requried. So, ignore the error.
|
||||
---@diagnostic disable:missing-fields
|
||||
treesitter.setup {
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
ensure_installed = { "c", "cpp", "javascript", "lua", "objc", "python", "rust", "vim" },
|
||||
auto_install = true,
|
||||
}
|
||||
|
||||
vim.treesitter.language.register("objcpp", { "objc", "cpp" })
|
||||
17
nvim/syntax/gocsstmpl.vim
Normal file
17
nvim/syntax/gocsstmpl.vim
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists("g:main_syntax")
|
||||
let g:main_syntax = 'css'
|
||||
endif
|
||||
|
||||
runtime! syntax/gotexttmpl.vim
|
||||
runtime! syntax/css.vim
|
||||
unlet b:current_syntax
|
||||
|
||||
syn cluster htmlPreproc add=gotplAction,goTplComment
|
||||
|
||||
let b:current_syntax = "gocsstmpl"
|
||||
|
||||
" vim: sw=2 ts=2 et
|
||||
Loading…
Add table
Add a link
Reference in a new issue