Move neovim config to dotfiles role
This commit is contained in:
parent
29e0b21a99
commit
65182a7c52
24 changed files with 0 additions and 0 deletions
22
Ansible/roles/dotfiles/files/neovim/UltiSnips/lua.snippets
Normal file
22
Ansible/roles/dotfiles/files/neovim/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
|
|
@ -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
|
|
@ -0,0 +1,4 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.softtabstop = 2
|
|
@ -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
|
|
@ -0,0 +1,4 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
vim.bo.shiftwidth = 2
|
||||
vim.bo.softtabstop = 2
|
18
Ansible/roles/dotfiles/files/neovim/after/ftplugin/lua.lua
Normal file
18
Ansible/roles/dotfiles/files/neovim/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
|
|
@ -0,0 +1,2 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
vim.opt.foldmethod = 'syntax'
|
15
Ansible/roles/dotfiles/files/neovim/after/ftplugin/zsh.lua
Normal file
15
Ansible/roles/dotfiles/files/neovim/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
|
|
@ -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,
|
||||
})
|
|
@ -0,0 +1,11 @@
|
|||
local treesitter_configs = require 'nvim-treesitter.configs'
|
||||
|
||||
treesitter_configs.setup {
|
||||
ensure_installed = { "lua", "vim", "javascript", "swift" },
|
||||
sync_install = true,
|
||||
auto_install = true,
|
||||
hightlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
}
|
7
Ansible/roles/dotfiles/files/neovim/after/syntax/css.vim
Normal file
7
Ansible/roles/dotfiles/files/neovim/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
|
|
@ -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"
|
||||
})
|
6
Ansible/roles/dotfiles/files/neovim/ftdetect/zsh.lua
Normal file
6
Ansible/roles/dotfiles/files/neovim/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",
|
||||
})
|
105
Ansible/roles/dotfiles/files/neovim/init.lua
Normal file
105
Ansible/roles/dotfiles/files/neovim/init.lua
Normal file
|
@ -0,0 +1,105 @@
|
|||
-- 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()
|
15
Ansible/roles/dotfiles/files/neovim/lua/autocommands.lua
Normal file
15
Ansible/roles/dotfiles/files/neovim/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,
|
||||
})
|
51
Ansible/roles/dotfiles/files/neovim/lua/colors.lua
Normal file
51
Ansible/roles/dotfiles/files/neovim/lua/colors.lua
Normal file
|
@ -0,0 +1,51 @@
|
|||
-- 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.cmd [[ color zaibatsu ]]
|
116
Ansible/roles/dotfiles/files/neovim/lua/configuration.lua
Normal file
116
Ansible/roles/dotfiles/files/neovim/lua/configuration.lua
Normal file
|
@ -0,0 +1,116 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
-- [[ Editor Confguration ]]
|
||||
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 = true
|
||||
|
||||
-- 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
|
||||
opt.textwidth = 120
|
||||
opt.colorcolumn = {80, 90, 120}
|
||||
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, and do some nice things when
|
||||
-- wrapping and joining and copying.
|
||||
opt.tabstop = 8
|
||||
opt.shiftwidth = 4
|
||||
opt.softtabstop = 4
|
||||
opt.shiftround = true
|
||||
opt.expandtab = true
|
||||
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
|
||||
|
||||
opt.backupdir = {vim.fn.stdpath("state") .. "/backup//"}
|
||||
opt.directory = {vim.fn.stdpath("state") .. "/swap//", "."}
|
||||
opt.undodir = {vim.fn.stdpath("state") .. "/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 = vim.fn.stdpath("state") .. "/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
Ansible/roles/dotfiles/files/neovim/lua/diagnostics.lua
Normal file
15
Ansible/roles/dotfiles/files/neovim/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 = '',
|
||||
},
|
||||
}
|
23
Ansible/roles/dotfiles/files/neovim/lua/gui.lua
Normal file
23
Ansible/roles/dotfiles/files/neovim/lua/gui.lua
Normal file
|
@ -0,0 +1,23 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
local function _init_neovide()
|
||||
if not vim.g.neovide then
|
||||
return
|
||||
end
|
||||
|
||||
vim.g.neovide_cursor_animation_length = 0
|
||||
vim.g.neovide_position_animation_length = 0
|
||||
vim.g.neovide_scroll_animation_length = 0
|
||||
|
||||
vim.o.guifont = "InputMonoCondensed:h16"
|
||||
|
||||
vim.cmd [[ colorscheme dracula ]]
|
||||
end
|
||||
|
||||
function init_gui()
|
||||
_init_neovide()
|
||||
end
|
||||
|
||||
return {
|
||||
init = init_gui,
|
||||
}
|
71
Ansible/roles/dotfiles/files/neovim/lua/keys.lua
Normal file
71
Ansible/roles/dotfiles/files/neovim/lua/keys.lua
Normal file
|
@ -0,0 +1,71 @@
|
|||
-- Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
local function init_key_opts()
|
||||
vim.g.mapleader = ","
|
||||
end
|
||||
|
||||
local function window_key_mappings()
|
||||
local map = vim.keymap.set
|
||||
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 map = vim.keymap.set
|
||||
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 set_up_local_lsp_mappings(buffer_number)
|
||||
local map = vim.keymap.set
|
||||
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
|
||||
|
||||
return {
|
||||
init_key_opts = init_key_opts,
|
||||
init_window_key_mappings = window_key_mappings,
|
||||
init_diagnostic_key_mappings = diagnostic_mappings,
|
||||
init_lsp_key_mappings = set_up_local_lsp_mappings,
|
||||
}
|
136
Ansible/roles/dotfiles/files/neovim/lua/lsp.lua
Normal file
136
Ansible/roles/dotfiles/files/neovim/lua/lsp.lua
Normal file
|
@ -0,0 +1,136 @@
|
|||
-- 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.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 = {
|
||||
command = 'clippy',
|
||||
extraArgs = {
|
||||
"--",
|
||||
"--no-deps",
|
||||
"-Dclippy::correctness",
|
||||
"-Dclippy::complexity",
|
||||
"-Wclippy::perf",
|
||||
"-Wclippy::pedantic",
|
||||
},
|
||||
},
|
||||
imports = {
|
||||
granularity = {
|
||||
group = "crate",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
16
Ansible/roles/dotfiles/files/neovim/lua/treesitter.lua
Normal file
16
Ansible/roles/dotfiles/files/neovim/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
Ansible/roles/dotfiles/files/neovim/syntax/gocsstmpl.vim
Normal file
17
Ansible/roles/dotfiles/files/neovim/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