refactor neovim config

This commit is contained in:
jc 2023-12-18 22:36:28 -05:00
commit fc8f483fa7
No known key found for this signature in database
43 changed files with 346 additions and 102 deletions

77
nvim/lua/.luarc.json Normal file
View file

@ -0,0 +1,77 @@
{
"workspace.library": [
"/home/jc/.local/share/nvim/lazy/neodev.nvim/types/stable",
"/home/jc/Applications/nvim-linux64/share/nvim/runtime/lua",
"/home/jc/.local/share/nvim/lazy/neodev.nvim/lua",
"/home/jc/.local/share/nvim/lazy/telescope.nvim/lua",
"/home/jc/.local/share/nvim/lazy/telescope-fzf-native.nvim/lua",
"/home/jc/.local/share/nvim/lazy/which-key.nvim/lua",
"/home/jc/.local/share/nvim/lazy/gitsigns.nvim/lua",
"/home/jc/.local/share/nvim/lazy/lsp-zero.nvim/lua",
"/home/jc/.local/share/nvim/lazy/nvim-dap-ui/lua",
"/home/jc/.local/share/nvim/lazy/todo-comments.nvim/lua",
"/home/jc/.local/share/nvim/lazy/nvim-lspconfig/lua",
"/home/jc/.local/share/nvim/lazy/lazy.nvim/lua",
"/home/jc/.local/share/nvim/lazy/mason.nvim/lua",
"/home/jc/.local/share/nvim/lazy/fzf-lua/lua",
"/home/jc/.local/share/nvim/lazy/nvim-treesitter-textobjects/lua",
"/home/jc/.local/share/nvim/lazy/mason-lspconfig.nvim/lua",
"/home/jc/.local/share/nvim/lazy/telescope-dap.nvim/lua",
"/home/jc/.local/share/nvim/lazy/nvim-web-devicons/lua",
"/home/jc/.local/share/nvim/lazy/telescope-file-browser.nvim/lua",
"/home/jc/.local/share/nvim/lazy/nvim-cmp/lua",
"/home/jc/.local/share/nvim/lazy/lualine.nvim/lua",
"/home/jc/.local/share/nvim/lazy/nvim-treesitter/lua",
"/home/jc/.local/share/nvim/lazy/nvim-ts-autotag/lua",
"/home/jc/.local/share/nvim/lazy/nvim-ts-context-commentstring/lua",
"/home/jc/.local/share/nvim/lazy/git.nvim/lua",
"/home/jc/.local/share/nvim/lazy/nvim-autopairs/lua",
"/home/jc/.local/share/nvim/lazy/Comment.nvim/lua",
"/home/jc/.local/share/nvim/lazy/rose-pine/lua",
"/home/jc/.local/share/nvim/lazy/indent-blankline.nvim/lua",
"/home/jc/.local/share/nvim/lazy/harpoon/lua",
"/home/jc/.local/share/nvim/lazy/LuaSnip/lua",
"/home/jc/.local/share/nvim/lazy/nvim-dap/lua",
"/home/jc/.local/share/nvim/lazy/cmp-nvim-lsp/lua",
"/home/jc/.local/share/nvim/lazy/plenary.nvim/lua",
"/home/jc/.local/share/nvim/lazy/null-ls.nvim/lua",
"/home/jc/.local/share/nvim/lazy/neodev.nvim/types/stable",
"/home/jc/Applications/nvim-linux64/share/nvim/runtime/lua",
"/home/jc/.local/share/nvim/lazy/neodev.nvim/lua",
"/home/jc/.local/share/nvim/lazy/telescope.nvim/lua",
"/home/jc/.local/share/nvim/lazy/telescope-fzf-native.nvim/lua",
"/home/jc/.local/share/nvim/lazy/which-key.nvim/lua",
"/home/jc/.local/share/nvim/lazy/gitsigns.nvim/lua",
"/home/jc/.local/share/nvim/lazy/lsp-zero.nvim/lua",
"/home/jc/.local/share/nvim/lazy/nvim-dap-ui/lua",
"/home/jc/.local/share/nvim/lazy/todo-comments.nvim/lua",
"/home/jc/.local/share/nvim/lazy/nvim-lspconfig/lua",
"/home/jc/.local/share/nvim/lazy/lazy.nvim/lua",
"/home/jc/.local/share/nvim/lazy/mason.nvim/lua",
"/home/jc/.local/share/nvim/lazy/fzf-lua/lua",
"/home/jc/.local/share/nvim/lazy/nvim-treesitter-textobjects/lua",
"/home/jc/.local/share/nvim/lazy/mason-lspconfig.nvim/lua",
"/home/jc/.local/share/nvim/lazy/telescope-dap.nvim/lua",
"/home/jc/.local/share/nvim/lazy/nvim-web-devicons/lua",
"/home/jc/.local/share/nvim/lazy/telescope-file-browser.nvim/lua",
"/home/jc/.local/share/nvim/lazy/nvim-cmp/lua",
"/home/jc/.local/share/nvim/lazy/lualine.nvim/lua",
"/home/jc/.local/share/nvim/lazy/nvim-treesitter/lua",
"/home/jc/.local/share/nvim/lazy/nvim-ts-autotag/lua",
"/home/jc/.local/share/nvim/lazy/nvim-ts-context-commentstring/lua",
"/home/jc/.local/share/nvim/lazy/git.nvim/lua",
"/home/jc/.local/share/nvim/lazy/nvim-autopairs/lua",
"/home/jc/.local/share/nvim/lazy/Comment.nvim/lua",
"/home/jc/.local/share/nvim/lazy/rose-pine/lua",
"/home/jc/.local/share/nvim/lazy/indent-blankline.nvim/lua",
"/home/jc/.local/share/nvim/lazy/harpoon/lua",
"/home/jc/.local/share/nvim/lazy/LuaSnip/lua",
"/home/jc/.local/share/nvim/lazy/nvim-dap/lua",
"/home/jc/.local/share/nvim/lazy/cmp-nvim-lsp/lua",
"/home/jc/.local/share/nvim/lazy/plenary.nvim/lua",
"/home/jc/.local/share/nvim/lazy/null-ls.nvim/lua",
"/home/jc/ghq/juancwu/dotfiles/nvim/lua",
"/home/jc/ghq/juancwu/dotfiles/nvim/lua",
"${3rd}/luv/library"
]
}

View file

@ -1 +0,0 @@
vim.opt.clipboard:append { "unnamedplus" }

View file

@ -1,14 +0,0 @@
-- vim.opt.clipboard:append { "unnamedplus" }
vim.g.clipboard = {
name = "xclip",
copy = {
['+'] = "xclip -sel clip -i -quiet",
['*'] = "xclip -sel primary -i -quiet",
},
paste = {
['+'] = "xclip -sel clip -o -quiet",
['*'] = "xclip -sel primary -o -quiet",
},
cache_enabled = 1,
}

View file

@ -1,12 +0,0 @@
vim.g.clipboard = {
name = "win32yank",
copy = {
['+'] = "win32yank.exe -i --crlf",
['*'] = "win32yank.exe -i --crlf",
},
paste = {
['+'] = "win32yank.exe -o --lf",
['*'] = "win32yank.exe -o --lf",
},
cache_enabled = 0,
}

View file

@ -0,0 +1,31 @@
local Utils = require("juancwu.utils")
if Utils.os.is_linux() then
vim.g.clipboard = {
name = "xclip",
copy = {
['+'] = "xclip -sel clip -i -quiet",
['*'] = "xclip -sel primary -i -quiet",
},
paste = {
['+'] = "xclip -sel clip -o -quiet",
['*'] = "xclip -sel primary -o -quiet",
},
cache_enabled = 1,
}
elseif Utils.os.is_mac() then
vim.opt.clipboard:append { "unnamedplus" }
elseif Utils.os.is_wsl() then
vim.g.clipboard = {
name = "win32yank",
copy = {
['+'] = "win32yank.exe -i --crlf",
['*'] = "win32yank.exe -i --crlf",
},
paste = {
['+'] = "win32yank.exe -o --lf",
['*'] = "win32yank.exe -o --lf",
},
cache_enabled = 0,
}
end

View file

@ -0,0 +1,150 @@
---@class Config
local M = {}
---@class ConfigOptions
local defaultOpts = {
---@type string | fun()
colorscheme = "rose-pine",
-- icons used by other plugins
icons = {
misc = {
dots = "󰇘",
},
dap = {
Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" },
Breakpoint = "",
BreakpointCondition = "",
BreakpointRejected = { "", "DiagnosticError" },
LogPoint = ".>",
},
diagnostics = {
Error = "",
Warn = "",
Hint = "",
Info = "",
},
git = {
added = "",
modified = "",
removed = "",
},
kinds = {
Array = "",
Boolean = "󰨙 ",
Class = "",
Codeium = "󰘦 ",
Color = "",
Control = "",
Collapsed = "",
Constant = "󰏿 ",
Constructor = "",
Copilot = "",
Enum = "",
EnumMember = "",
Event = "",
Field = "",
File = "",
Folder = "",
Function = "󰊕 ",
Interface = "",
Key = "",
Keyword = "",
Method = "󰊕 ",
Module = "",
Namespace = "󰦮 ",
Null = "",
Number = "󰎠 ",
Object = "",
Operator = "",
Package = "",
Property = "",
Reference = "",
Snippet = "",
String = "",
Struct = "󰆼 ",
TabNine = "󰏚 ",
Text = "",
TypeParameter = "",
Unit = "",
Value = "",
Variable = "󰀫 ",
},
},
---@type table<string, string[]|boolean>?
kind_filter = {
default = {
"Class",
"Constructor",
"Enum",
"Field",
"Function",
"Interface",
"Method",
"Module",
"Namespace",
"Package",
"Property",
"Struct",
"Trait",
},
markdown = false,
help = false,
-- you can specify a different filter for each filetype
lua = {
"Class",
"Constructor",
"Enum",
"Field",
"Function",
"Interface",
"Method",
"Module",
"Namespace",
-- "Package", -- remove package since luals uses it for control flow structures
"Property",
"Struct",
"Trait",
},
},
}
---@param name "options" | "keymaps" | "clipboard"
function M.load(name)
local mod = "juancwu.config." .. name
local error_handler = function(err)
local msg = "Failed loading " .. mod .. "\n\n" .. err
print(msg)
end
xpcall(function()
require(mod)
end, error_handler)
end
---@type ConfigOptions
local options
---@param opts? ConfigOptions
function M.setup(opts)
options = vim.tbl_deep_extend("force", defaultOpts, opts or {}) or {}
M.load("options")
M.load("keymaps")
M.load("clipboard")
require("lazy").setup("juancwu.plugins")
-- try to load colorscheme
xpcall(function()
if type(options.colorscheme) == "function" then
options.colorscheme()
else
vim.cmd.colorscheme(options.colorscheme)
end
end, function(err)
local msg = "Failed to load colorscheme " .. options.colorscheme .. "\n\n" .. err
print(msg)
vim.cmd.colorscheme("rose-pine")
end)
end
return M

View file

@ -1,6 +1,3 @@
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- easy escape
vim.keymap.set("i", "<C-[>", "<Esc>", { noremap = true, silent = true })
vim.keymap.set("v", "<C-[>", "<Esc>", { noremap = true, silent = true })

View file

@ -1,3 +1,6 @@
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.scriptencoding = "utf-8"
vim.opt.encoding = "utf-8"
vim.opt.fileencoding = "utf-8"
@ -47,11 +50,11 @@ vim.opt.undofile = true
-- [[ highlight on yank ]]
local highligh_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
vim.api.nvim_create_autocmd('TextYankPost', {
callback = function()
vim.highlight.on_yank()
end,
group = highligh_group,
pattern = '*',
callback = function()
vim.highlight.on_yank()
end,
group = highligh_group,
pattern = '*',
})

View file

@ -0,0 +1,8 @@
local M = {}
---@param opts? ConfigOptions
function M.setup(opts)
require("juancwu.config").setup(opts)
end
return M

View file

@ -0,0 +1,15 @@
return {
{
"rose-pine/nvim",
name = "rose-pine",
priority = 1000,
},
{
'navarasu/onedark.nvim',
priority = 1000,
},
{
"craftzdog/solarized-osaka.nvim",
priority = 1000,
}
}

View file

@ -17,8 +17,17 @@ return {
{ 'hrsh7th/nvim-cmp' }, -- Required
{ 'hrsh7th/cmp-nvim-lsp' }, -- Required
{ 'L3MON4D3/LuaSnip' }, -- Required
-- Neovim Plugin Development Completions
{
'folke/neodev.nvim',
opts = {},
},
},
config = function()
-- required to setup neodev before lspconfig
require('neodev').setup({})
local lspzero = require("lsp-zero")
lspzero.preset({})

View file

@ -0,0 +1,10 @@
---@class Utils
---@field os juancwu.utils.os
local M = setmetatable({}, {
__index = function(t, k)
t[k] = require("juancwu.utils." .. k)
return t[k]
end
})
return M

View file

@ -0,0 +1,24 @@
---@class juancwu.utils.os
local M = {}
---@return boolean
function M.is_linux()
return vim.loop.os_uname().sysname:find("Linux") ~= nil
end
---@return boolean
function M.is_mac()
return vim.loop.os_uname().sysname:find("Darwin") ~= nil
end
---@return boolean
function M.is_win()
return vim.loop.os_uname().sysname:find("Windows") ~= nil
end
---@return boolean
function M.is_wsl()
return vim.fn.has("wsl") == 1
end
return M

View file

@ -1,20 +0,0 @@
return {
{
"rose-pine/nvim",
name = "rose-pine",
priority = 1000,
enabled = true,
config = function()
vim.cmd.colorscheme("rose-pine")
end
},
{
-- Theme inspired by Atom
'navarasu/onedark.nvim',
priority = 1000,
enabled = false,
config = function()
vim.cmd.colorscheme 'onedark'
end,
},
}

View file

@ -1,10 +0,0 @@
return {
"folke/neodev.nvim",
enabled = false,
opts = {
library = {
plugins = true,
types = true,
}
}
}

View file

@ -1,7 +0,0 @@
return {
"rose-pine/nvim",
name = "rose-pine",
opts = function()
vim.cmd.colorscheme("rose-pine")
end
}