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

View file

@ -11,25 +11,6 @@ if not vim.loop.fs_stat(lazypath) then
end
vim.opt.rtp:prepend(lazypath)
local has = vim.fn.has
local is_mac = has "macunix"
local is_wsl = has "wsl"
local is_unix = has "unix"
-- custom modules:
require("keymaps")
require("options")
if is_wsl == 1 then
require("clipboard-wsl")
end
if is_mac == 1 then
require("clipboard-macos")
end
if is_unix == 1 and is_mac ~= 1 then
require("clipboard-unix")
end
require("lazy").setup("plugins")
require("juancwu.config").setup({
colorscheme = "solarized-osaka",
})

View file

@ -14,6 +14,7 @@
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "9453e3d6cd2ca45d96e20f343e8f1b927364b630" },
"mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" },
"neodev.nvim": { "branch": "main", "commit": "be6bf4f5d2d3b173c9291f074130a3d29e1af78a" },
"null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" },
"nvim-autopairs": { "branch": "master", "commit": "0f04d78619cce9a5af4f355968040f7d675854a1" },
"nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" },
@ -25,8 +26,10 @@
"nvim-ts-autotag": { "branch": "main", "commit": "8515e48a277a2f4947d91004d9aa92c29fdc5e18" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "1277b4a1f451b0f18c0790e1a7f12e1e5fdebfee" },
"nvim-web-devicons": { "branch": "master", "commit": "a1425903ab52a0a0460622519e827f224e5b4fee" },
"onedark.nvim": { "branch": "master", "commit": "c5476a091b0f1b4e853db91c91ff941f848a1cdd" },
"plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" },
"rose-pine": { "branch": "main", "commit": "92762f4fa2144c05db760ea254f4c399a56a7ef5" },
"solarized-osaka.nvim": { "branch": "main", "commit": "83b7026ac7a4e185d4ecbe99926fd94b5735e2ea" },
"telescope-dap.nvim": { "branch": "master", "commit": "4e2d5efb92062f0b865fe59b200b5ed7793833bf" },
"telescope-file-browser.nvim": { "branch": "master", "commit": "98101b22402cd6d1c7e9a7e0c4718bfc98cb1625" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },

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"

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
}