Skip to content

Commit

Permalink
Refactor Neovim config using Lua and lazy.nvim
Browse files Browse the repository at this point in the history
  • Loading branch information
vicnett committed Nov 7, 2024
1 parent bc80c69 commit 626167c
Show file tree
Hide file tree
Showing 52 changed files with 260 additions and 268 deletions.
1 change: 0 additions & 1 deletion vim/after/ftplugin/sql.vim

This file was deleted.

12 changes: 12 additions & 0 deletions vim/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"

-- Config files
require("config.general")
require("config.abbreviations")
require("config.formatting")
require("config.remaps")
require("config.visual")

-- Plugin manager
require("config.lazy")
33 changes: 0 additions & 33 deletions vim/init.vim

This file was deleted.

26 changes: 26 additions & 0 deletions vim/lazy-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"bullets.vim": { "branch": "master", "commit": "2253f970e54320dbd76fd6bb4f5a0bf2436ce232" },
"csv.vim": { "branch": "master", "commit": "bddfcbadd788ab11eb3dbba4550a38a412fe3705" },
"lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" },
"nvim-solarized-lua": { "branch": "master", "commit": "d69a263c97cbc765ca442d682b3283aefd61d4ac" },
"tcomment_vim": { "branch": "master", "commit": "48ab639a461d9b8344f7fee06cb69b4374863b13" },
"vim-css-color": { "branch": "master", "commit": "950e80352b325ff26d3b0faf95b29e301c200f7d" },
"vim-easy-align": { "branch": "master", "commit": "9815a55dbcd817784458df7a18acacc6f82b1241" },
"vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" },
"vim-gitgutter": { "branch": "main", "commit": "7b0b5098e3e57be86bb96cfbf2b8902381eef57c" },
"vim-gutentags": { "branch": "master", "commit": "aa47c5e29c37c52176c44e61c780032dfacef3dd" },
"vim-lastplace": { "branch": "master", "commit": "e58cb0df716d3c88605ae49db5c4741db8b48aa9" },
"vim-obsession": { "branch": "master", "commit": "ed9dfc7c2cc917ace8b24f4f9f80a91e05614b63" },
"vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" },
"vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" },
"vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" },
"vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" },
"vim-system-copy": { "branch": "master", "commit": "8abd9ed21016bdc21b458c79da3b9ac0ee25c1ce" },
"vim-textobj-codeblock": { "branch": "master", "commit": "7658826f1a13a2865fb65b64481c40968fd780c1" },
"vim-textobj-entire": { "branch": "master", "commit": "64a856c9dff3425ed8a863b9ec0a21dbaee6fb3a" },
"vim-textobj-indent": { "branch": "master", "commit": "deb76867c302f933c8f21753806cbf2d8461b548" },
"vim-textobj-line": { "branch": "master", "commit": "1a6780d29adcf7e464e8ddbcd0be0a9df1a37339" },
"vim-textobj-quotes": { "branch": "master", "commit": "cca9686acf7b21d930ced1801120ecf23fb2f995" },
"vim-textobj-user": { "branch": "master", "commit": "41a675ddbeefd6a93664a4dc52f302fe3086a933" },
"vim-wordmotion": { "branch": "master", "commit": "81d9bd298376ab0dc465c85d55afa4cb8d5f47a1" }
}
5 changes: 5 additions & 0 deletions vim/lua/config/abbreviations.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- Vertical split find
vim.keymap.set('ca', 'vsfind', 'vert sfind')

-- Vertical split existing buffer
vim.keymap.set('ca', 'vsb', 'vert sbuffer')
22 changes: 22 additions & 0 deletions vim/lua/config/formatting.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- Formatting settings
----------------------

-- Set maximum line length
vim.opt.textwidth = 80

-- Formatting options:
-- j Remove comment leaders when joining lines (where it makes sense)
-- tc Auto-wrap in both text and comments
-- r Continue comment on new line when hitting <Enter> in insert mode
-- o Continue comment on new line when hitting "o" or "O"
-- q Allow formatting comments with "gq"
-- l Don't automatically break the line if it was already longer than
-- 'textwidth' when the insert command started
-- 1 Don't break a line after a one-letter word; break it before it if possible
vim.opt.formatoptions = jtcroql1

-- 2 space indentation
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.shiftround = true
vim.opt.expandtab = true
18 changes: 18 additions & 0 deletions vim/lua/config/general.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- General Vim Settings
-- --------------------

-- vim.g.python_indent = {}
-- vim.g.python_indent.open_paren = 'shiftwidth()'
-- vim.g.python_indent.closed_paren_align_last_line = v:false

vim.g.python_indent = {
open_paren = 'shiftwidth()',
closed_paren_align_last_line = false,
}

-- Fuzzy file finding
vim.opt.path:append '**'

-- Assume POSIX-compliant shell syntax for highlighting purposes, when other
-- detection methods fail
vim.g.is_posix = 1
33 changes: 33 additions & 0 deletions vim/lua/config/lazy.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)

-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- import your plugins
{ import = "plugins" },
},
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "solarized" } },
-- automatically check for plugin updates
checker = { enabled = true },
change_detection = {
-- automatically check for config file changes and reload the ui
enabled = true,
notify = false, -- don't get a notification when changes are found
}
})
9 changes: 9 additions & 0 deletions vim/lua/config/remaps.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Alt + j/k to move current line down/up in normal mode
vim.keymap.set("n", "<A-j>", ":m .+1<CR>==")
vim.keymap.set("n", "<A-k>", ":m .-2<CR>==")
-- in insert mode
vim.keymap.set("i", "<A-j>", "<Esc>:m .+1<CR>==gi")
vim.keymap.set("i", "<A-k>", "<Esc>:m .-2<CR>==gi")
-- and in visual mode
vim.keymap.set("v", "<A-j>", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "<A-k>", ":m '<-2<CR>gv=gv")
53 changes: 53 additions & 0 deletions vim/lua/config/visual.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
-- Visual settings
------------------

-- Make it obvious where the textwidth limit is
vim.opt.colorcolumn = '+1'

-- Display extra whitespace
vim.opt.list = true
vim.opt.listchars:append {
tab = "",
leadmultispace = "",
trail = "·",
nbsp = "·",
multispace = "·",
}

-- Display relative line numbers, with absolute line number for current line
vim.opt.number = true
vim.opt.numberwidth = 5
vim.opt.relativenumber = true

-- Automatically turn off relative line numbers when not in focus
-- ... But also don't turn them on and off for help buffers!
local numbertogglegroup =
vim.api.nvim_create_augroup('numbertoggle', { clear = true })
vim.api.nvim_create_autocmd({ 'BufEnter', 'FocusGained', 'InsertLeave' }, {
callback = function()
if vim.bo.filetype ~= 'help' then
vim.opt.relativenumber = true
end
end,
group = numbertogglegroup,
pattern = '*',
})
vim.api.nvim_create_autocmd({ 'BufLeave', 'FocusLost', 'InsertEnter' }, {
callback = function()
vim.opt.relativenumber = false
end,
group = numbertogglegroup,
pattern = '*',
})

-- Open new split panes to right and bottom
vim.opt.splitbelow = true
vim.opt.splitright = true

-- Ignore whitespace only changes in diff, always use vertical diffs
vim.opt.diffopt:append {
iwhite,
vertical,
'linematch:60',
algorithm = histogram,
}
3 changes: 3 additions & 0 deletions vim/lua/plugins/bullets.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
{ 'bullets-vim/bullets.vim' }
}
3 changes: 3 additions & 0 deletions vim/lua/plugins/css-color.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
{ 'ap/vim-css-color' }
}
3 changes: 3 additions & 0 deletions vim/lua/plugins/csv.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
{ 'chrisbra/csv.vim' }
}
11 changes: 11 additions & 0 deletions vim/lua/plugins/easy-align.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
return {
{
'junegunn/vim-easy-align',
keys = {
-- Start interactive EasyAlign in visual mode (e.g. vipga)
{ "ga", "<Plug>(EasyAlign)", mode = "x" },
-- Start interactive EasyAlign for a motion/text object (e.g. gaip)
{ "ga", "<Plug>(EasyAlign)" },
},
}
}
3 changes: 3 additions & 0 deletions vim/lua/plugins/fugitive.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
{ 'tpope/vim-fugitive' }
}
3 changes: 3 additions & 0 deletions vim/lua/plugins/gitgutter.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
{ 'airblade/vim-gitgutter' }
}
3 changes: 3 additions & 0 deletions vim/lua/plugins/gutentags.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
{ 'ludovicchabant/vim-gutentags' }
}
3 changes: 3 additions & 0 deletions vim/lua/plugins/lastplace.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
{ 'farmergreg/vim-lastplace' }
}
10 changes: 10 additions & 0 deletions vim/lua/plugins/nvim-solarized-lua.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
return {
{
'ishan9299/nvim-solarized-lua',
lazy = false,
priority = 1000,
config = function()
vim.cmd([[ colorscheme solarized ]])
end,
},
}
3 changes: 3 additions & 0 deletions vim/lua/plugins/obsession.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
{ 'tpope/vim-obsession' }
}
3 changes: 3 additions & 0 deletions vim/lua/plugins/repeat.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
{ 'tpope/vim-repeat' }
}
3 changes: 3 additions & 0 deletions vim/lua/plugins/rhubarb.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
{ 'tpope/vim-rhubarb' }
}
3 changes: 3 additions & 0 deletions vim/lua/plugins/sleuth.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
{ 'tpope/vim-sleuth' }
}
3 changes: 3 additions & 0 deletions vim/lua/plugins/surround.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
{ 'tpope/vim-surround' }
}
3 changes: 3 additions & 0 deletions vim/lua/plugins/system-copy.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
{ 'christoomey/vim-system-copy' }
}
3 changes: 3 additions & 0 deletions vim/lua/plugins/tcomment.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
return {
{ 'tomtom/tcomment_vim' }
}
11 changes: 11 additions & 0 deletions vim/lua/plugins/text-objects.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
return {
{
"kana/vim-textobj-user",
priority = 100,
},
{ "kana/vim-textobj-line" },
{ "kana/vim-textobj-indent" },
{ "kana/vim-textobj-entire" },
{ "beloglazov/vim-textobj-quotes" },
{ "christoomey/vim-textobj-codeblock" },
}
8 changes: 8 additions & 0 deletions vim/lua/plugins/wordmotion.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
return {
{
'chaoren/vim-wordmotion',
init = function()
vim.g.wordmotion_prefix = '<leader>'
end,
},
}
7 changes: 0 additions & 7 deletions vim/rcfiles/abbreviations

This file was deleted.

18 changes: 0 additions & 18 deletions vim/rcfiles/formatting

This file was deleted.

39 changes: 0 additions & 39 deletions vim/rcfiles/general

This file was deleted.

Loading

0 comments on commit 626167c

Please sign in to comment.