-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial pass at a neovim config
- Loading branch information
Showing
19 changed files
with
5,867 additions
and
2 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
-- Load existing vim configuration | ||
-- vim.cmd("source $XDG_CONFIG_HOME/vim/vimrc") | ||
|
||
-- Disable newrw | ||
vim.g.loaded_netrw = 1 | ||
vim.g.loaded_netrwPlugin = 1 | ||
|
||
-- Styling | ||
vim.opt.cursorline = true | ||
vim.opt.number = true | ||
vim.opt.termguicolors = true | ||
vim.opt.scrolloff = 5 | ||
vim.opt.showtabline = 2 | ||
vim.opt.title = true | ||
|
||
-- Tab configuration | ||
vim.opt.tabstop = 2 | ||
vim.opt.softtabstop = 2 | ||
vim.opt.shiftwidth = 2 | ||
|
||
-- Backups | ||
vim.opt.backup = true | ||
vim.opt.backupdir = vim.env.XDG_DATA_HOME .. "/nvim/backup" | ||
|
||
-- Navigate by visual line instead of logical line | ||
vim.keymap.set("", "<up>", "gk") | ||
vim.keymap.set("", "<down>", "gj") | ||
|
||
-- Load vim-plug | ||
local Plug = require('usermod.vimplug') | ||
|
||
Plug.begin() | ||
|
||
-- THEMING | ||
require('usermod.themes.sonokai') | ||
require('usermod.plugins.nvim-web-devicons') | ||
|
||
-- PLUGINS (load order is important) | ||
require('usermod.plugins.gitsigns') | ||
require('usermod.plugins.lualine') | ||
require('usermod.plugins.barbar') | ||
require('usermod.plugins.nvim-cmp') | ||
require('usermod.plugins.nvim-lspconfig') | ||
require('usermod.plugins.nvim-treesitter') | ||
require('usermod.plugins.nvim-tree') | ||
require('usermod.plugins.lsp_lines') | ||
|
||
require('usermod.plugins.hover') | ||
require('usermod.plugins.nvim-surround') | ||
require('usermod.plugins.commentary') | ||
|
||
Plug.ends() | ||
|
||
local function vim_enter(data) | ||
local tree = require("nvim-tree.api").tree | ||
|
||
-- buffer is a real file on the disk | ||
local real_file = vim.fn.filereadable(data.file) == 1 | ||
|
||
-- buffer is a [No Name] | ||
local no_name = data.file == "" and vim.bo[data.buf].buftype == "" | ||
|
||
if real_file or no_name then | ||
local code_len = string.len(vim.env.CODE_HOME) | ||
if string.sub(data.file, 1, code_len) == vim.env.CODE_HOME then | ||
local first_sep = string.find(data.file, "/", code_len + 2) | ||
local root_end = first_sep and string.find(data.file, "/", first_sep + 1) or code_len | ||
local root = string.sub(data.file, 1, root_end) | ||
vim.cmd.cd(root) | ||
|
||
if not data.file:match("/%.git/") then | ||
-- open the tree, find the file but don't focus it | ||
tree.toggle({ focus = false, find_file = true, path = root }) | ||
end | ||
else | ||
-- open the tree, find the file but don't focus it | ||
tree.toggle({ focus = false, find_file = true }) | ||
end | ||
end | ||
end | ||
|
||
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = vim_enter }) | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
vim.g.barbar_auto_setup = false | ||
|
||
require('usermod.vimplug')('romgrk/barbar.nvim', { | ||
config = function() | ||
require('barbar').setup({}) | ||
|
||
local map = vim.api.nvim_set_keymap | ||
local opts = { noremap = true, silent = true } | ||
|
||
-- Move to previous/next | ||
map('n', '<A-,>', '<Cmd>BufferPrevious<CR>', opts) | ||
map('n', '<A-.>', '<Cmd>BufferNext<CR>', opts) | ||
|
||
-- Re-order to previous/next | ||
-- map('n', '<A-<>', '<Cmd>BufferMovePrevious<CR>', opts) | ||
-- map('n', '<A->>', '<Cmd>BufferMoveNext<CR>', opts) | ||
|
||
-- -- Goto buffer in position... | ||
-- map('n', '<A-1>', '<Cmd>BufferGoto 1<CR>', opts) | ||
-- map('n', '<A-2>', '<Cmd>BufferGoto 2<CR>', opts) | ||
-- map('n', '<A-3>', '<Cmd>BufferGoto 3<CR>', opts) | ||
-- map('n', '<A-4>', '<Cmd>BufferGoto 4<CR>', opts) | ||
-- map('n', '<A-5>', '<Cmd>BufferGoto 5<CR>', opts) | ||
-- map('n', '<A-6>', '<Cmd>BufferGoto 6<CR>', opts) | ||
-- map('n', '<A-7>', '<Cmd>BufferGoto 7<CR>', opts) | ||
-- map('n', '<A-8>', '<Cmd>BufferGoto 8<CR>', opts) | ||
-- map('n', '<A-9>', '<Cmd>BufferGoto 9<CR>', opts) | ||
-- map('n', '<A-0>', '<Cmd>BufferLast<CR>', opts) | ||
|
||
-- Pin/unpin buffer | ||
-- map('n', '<A-p>', '<Cmd>BufferPin<CR>', opts) | ||
|
||
-- Close buffer | ||
map('n', '<A-c>', '<Cmd>BufferClose<CR>', opts) | ||
|
||
-- Wipeout buffer | ||
-- :BufferWipeout | ||
|
||
-- Close commands | ||
-- :BufferCloseAllButCurrent | ||
-- :BufferCloseAllButPinned | ||
-- :BufferCloseAllButCurrentOrPinned | ||
-- :BufferCloseBuffersLeft | ||
-- :BufferCloseBuffersRight | ||
|
||
-- Magic buffer-picking mode | ||
-- map('n', '<C-p>', '<Cmd>BufferPick<CR>', opts) | ||
|
||
-- Sort automatically by... | ||
-- map('n', '<Space>bb', '<Cmd>BufferOrderByBufferNumber<CR>', opts) | ||
-- map('n', '<Space>bn', '<Cmd>BufferOrderByName<CR>', opts) | ||
-- map('n', '<Space>bd', '<Cmd>BufferOrderByDirectory<CR>', opts) | ||
-- map('n', '<Space>bl', '<Cmd>BufferOrderByLanguage<CR>', opts) | ||
-- map('n', '<Space>bw', '<Cmd>BufferOrderByWindowNumber<CR>', opts) | ||
end | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require('usermod.vimplug')('tpope/vim-commentary', { | ||
config = function() | ||
vim.api.nvim_create_autocmd("FileType", { | ||
pattern = { | ||
"gleam", | ||
}, | ||
command = "setlocal commentstring =//\\ %s", | ||
}) | ||
end | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require('usermod.vimplug')('lewis6991/gitsigns.nvim', { | ||
config = function() | ||
require('gitsigns').setup() | ||
end | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require('usermod.vimplug')('lewis6991/hover.nvim', { | ||
config = function() | ||
require('hover').setup({ | ||
init = function() | ||
-- Require providers | ||
require("hover.providers.lsp") | ||
-- require('hover.providers.gh') | ||
-- require('hover.providers.gh_user') | ||
-- require('hover.providers.jira') | ||
-- require('hover.providers.dap') | ||
-- require('hover.providers.man') | ||
-- require('hover.providers.dictionary') | ||
end, | ||
mouse_providers = { "LSP" }, | ||
mouse_delay = 1000, | ||
}) | ||
|
||
-- Setup keymaps | ||
vim.keymap.set("n", "K", require("hover").hover, {desc = "hover.nvim"}) | ||
vim.keymap.set("n", "gK", require("hover").hover_select, {desc = "hover.nvim (select)"}) | ||
vim.keymap.set("n", "<C-p>", function() require("hover").hover_switch("previous") end, {desc = "hover.nvim (previous source)"}) | ||
vim.keymap.set("n", "<C-n>", function() require("hover").hover_switch("next") end, {desc = "hover.nvim (next source)"}) | ||
|
||
-- Mouse support | ||
-- vim.keymap.set('n', '<MouseMove>', require('hover').hover_mouse, { desc = "hover.nvim (mouse)" }) | ||
-- vim.o.mousemoveevent = true | ||
end | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require('usermod.vimplug')('https://git.sr.ht/~whynothugo/lsp_lines.nvim', { | ||
as = "lsp_lines", | ||
config = function() | ||
require('lsp_lines').setup() | ||
end | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require('usermod.vimplug')('nvim-lualine/lualine.nvim', { | ||
config = function() | ||
require('lualine').setup({ | ||
options = { | ||
icons_enabled = true, | ||
theme = require('lualine.themes.horizon'), | ||
component_separators = { left = '\u{e0bf}', right = '\u{e0bd}'}, | ||
section_separators = { left = '\u{e0b8}', right = '\u{e0ba}'}, | ||
globalstatus = true, | ||
ignore_focus = { "NvimTree", "help" }, | ||
}, | ||
extensions = { "nvim-tree" }, | ||
}) | ||
end | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
local Plug = require('usermod.vimplug') | ||
|
||
Plug('hrsh7th/cmp-nvim-lsp') | ||
|
||
Plug('hrsh7th/nvim-cmp', { | ||
config = function() | ||
local cmp = require('cmp') | ||
|
||
cmp.setup({ | ||
snippet = { | ||
expand = function(args) | ||
vim.snippet.expand(args.body) | ||
end, | ||
}, | ||
window = { | ||
-- completion = cmp.config.window.bordered(), | ||
-- documentation = cmp.config.window.bordered(), | ||
}, | ||
mapping = cmp.mapping.preset.insert({ | ||
['<C-Space>'] = cmp.mapping.complete(), | ||
['C-e>'] = cmp.mapping.abort(), | ||
['<CR>'] = cmp.mapping.confirm({ select = true }), | ||
}), | ||
sources = cmp.config.sources({ | ||
{ name ='nvim_lsp' }, | ||
}), | ||
}) | ||
end | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require('usermod.vimplug')('neovim/nvim-lspconfig', { | ||
config = function() | ||
-- Disable virtual_text since it's redundant due to lsp_lines. | ||
vim.diagnostic.config({ | ||
virtual_text = false, | ||
}) | ||
|
||
local lspconfig = require('lspconfig') | ||
local capabilities = require('cmp_nvim_lsp').default_capabilities() | ||
|
||
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md | ||
lspconfig.eslint.setup({ | ||
capabilities = capabilities, | ||
on_attach = function(client, bufnr) | ||
vim.api.nvim_create_autocmd("BufWritePre", { | ||
buffer = bufnr, | ||
command = "EslintFixAll", | ||
}) | ||
end, | ||
}) | ||
lspconfig.gleam.setup({ capabilities = capabilities }) | ||
lspconfig.rust_analyzer.setup({ capabilities = capabilities }) | ||
|
||
-- Autoformat code for LSP's that support it | ||
vim.api.nvim_create_autocmd("BufWritePre", { | ||
pattern = { | ||
"*.gleam", | ||
"*.rs", | ||
}, | ||
callback = function() vim.lsp.buf.format({}) end, | ||
}) | ||
end | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require('usermod.vimplug')('kylechui/nvim-surround', { | ||
config = function() | ||
require("nvim-surround").setup({}) | ||
end | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
require('usermod.vimplug')('nvim-tree/nvim-tree.lua', { | ||
config = function() | ||
require("nvim-tree").setup({ | ||
auto_reload_on_write = true, | ||
on_attach = function(bufnr) | ||
local api = require('nvim-tree.api') | ||
local function opts(desc) | ||
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } | ||
end | ||
|
||
-- Attach all the default mappings | ||
api.config.mappings.default_on_attach(bufnr) | ||
|
||
-- Remove unwanted mappings | ||
vim.keymap.del('n', '<C-]>', { buffer = bufnr }) | ||
vim.keymap.del('n', 'g?', { buffer = bufnr }) | ||
vim.keymap.del('n', 's', { buffer = bufnr }) | ||
|
||
-- Add our own mappings | ||
vim.keymap.set('n', '?', api.tree.toggle_help, opts('Help')) | ||
end, | ||
view = { | ||
width = 30, | ||
}, | ||
git = { | ||
enable = true, | ||
}, | ||
filters = { | ||
git_ignored = false, | ||
git_clean = false, | ||
}, | ||
diagnostics = { | ||
enable = true, | ||
show_on_dirs = false, | ||
icons = { | ||
hint = "", | ||
info = "", | ||
warning = "", | ||
error = "", | ||
}, | ||
}, | ||
log = { | ||
enable = false, | ||
truncate = false, | ||
types = { | ||
all = false, | ||
config = false, | ||
copy_paste = false, | ||
diagnostics = false, | ||
git = false, | ||
profile = false, | ||
}, | ||
}, | ||
renderer = { | ||
indent_markers = { | ||
enable = true, | ||
inline_arrows = true, | ||
icons = { | ||
corner = "┖", | ||
edge = "┃", | ||
item = "┠", | ||
bottom = "─", | ||
none = " ", | ||
} | ||
}, | ||
icons = { | ||
git_placement = "after", | ||
glyphs = { | ||
git = { | ||
-- don't call out staged changes explicitly | ||
staged = "", | ||
unstaged = "✗", | ||
unmerged = "\u{f4db}", | ||
renamed = "\u{f45a}", | ||
untracked = "\u{f4dd}", | ||
deleted = "\u{f4dc}", | ||
ignored = "\u{e668}", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
vim.keymap.set("n", "<space>s", require('nvim-tree.api').tree.toggle, { silent = true, desc = 'toggle nvim-tree' }) | ||
end | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require('usermod.vimplug')('nvim-treesitter/nvim-treesitter', { | ||
run = ":TSUpdate", | ||
config = function() | ||
require('nvim-treesitter.configs').setup({ | ||
ensure_installed = { | ||
"yaml", "json", "json5", "markdown", "toml", | ||
"lua", "vim", | ||
"perl", | ||
"javascript", "typescript", | ||
"gleam", "rust" | ||
}, | ||
highlight = { | ||
enable = true, | ||
}, | ||
}) | ||
end | ||
}) | ||
|
Oops, something went wrong.