1
0
Fork 0

minor neovim config refactor

This commit is contained in:
Luca Bilke 2024-04-16 10:13:40 +02:00
parent df30a0ba0a
commit 2df615a77a
12 changed files with 52 additions and 53 deletions

View File

@ -1,4 +1,4 @@
_G.Custom = require("custom") _G.Config = require("config")
_G.Lib = require("lib") _G.Lib = require("lib")
require("config.lazy") require("config.lazy")

View File

@ -0,0 +1,17 @@
---@class config
---@field ui config.ui
---@field language config.language
---@field shortcuts config.shortcuts
---@field secrets? config.secrets
local M = {}
setmetatable(M, {
__index = function(_, k)
local ok, mod = pcall(require, "config." .. k)
if ok then
return mod
end
end,
})
return M

View File

@ -1,11 +1,12 @@
---@diagnostic disable: missing-fields ---@diagnostic disable: missing-fields
---@class custom.language ---@class config.language
local M = {} local M = {}
---@type table<string, conform.FormatterUnit> ---@type table<string, conform.FormatterUnit>
M.formatters_by_ft = { M.formatters_by_ft = {
lua = { "stylua" }, lua = { "stylua" },
sh = { "shfmt" }, sh = { "shfmt" },
python = { "black" },
} }
---@type table<string, conform.FormatterConfigOverride|fun(bufnr: integer): nil|conform.FormatterConfigOverride> ---@type table<string, conform.FormatterConfigOverride|fun(bufnr: integer): nil|conform.FormatterConfigOverride>
@ -158,16 +159,10 @@ M.lsp_setup = {
LazyVim.lsp.on_attach(function(client, _) LazyVim.lsp.on_attach(function(client, _)
if client.name == "ruff_lsp" then if client.name == "ruff_lsp" then
client.server_capabilities.hoverProvider = false client.server_capabilities.hoverProvider = false
client.server_capabilities.renameProvider = false
end end
end) end)
end, end,
-- marksman = function()
-- LazyVim.lsp.on_attach(function(client, _)
-- if client.name == "marksman" then
-- client.server_capabilities.hoverProvider = false
-- end
-- end)
-- end,
rust_analyzer = function() rust_analyzer = function()
return true return true
end, end,

View File

@ -14,3 +14,4 @@ g.loaded_node_provider = 0
g.loaded_perl_provider = 0 g.loaded_perl_provider = 0
g.loaded_python3_provider = 0 g.loaded_python3_provider = 0
g.loaded_ruby_provider = 0 g.loaded_ruby_provider = 0
g.autoformat = false

View File

@ -1,5 +1,5 @@
-- NOTE: Managed by shortcuts script -- NOTE: Managed by shortcuts script
---@class custom.shortcuts ---@class config.shortcuts
return { return {
gh = "/home/luca", gh = "/home/luca",
gch = "/home/luca/.cache", gch = "/home/luca/.cache",

View File

@ -1,4 +1,4 @@
---@class custom.ui ---@class config.ui
local M = {} local M = {}
---@type Array<string> ---@type Array<string>

View File

@ -1,18 +0,0 @@
---@class custom
---@field ui custom.ui
---@field language custom.language
---@field shortcuts custom.shortcuts
---@field prompts custom.prompts
---@field secrets? custom.secrets
local M = {}
setmetatable(M, {
__index = function(_, k)
local ok, mod = pcall(require, "custom." .. k)
if ok then
return mod
end
end,
})
return M

View File

@ -2,7 +2,7 @@ local M = {}
---@return table<string, function> ---@return table<string, function>
function M.generate_shortcut_maps() function M.generate_shortcut_maps()
local shortcuts = Custom.shortcuts local shortcuts = Config.shortcuts
local fs = require("neo-tree.sources.filesystem") local fs = require("neo-tree.sources.filesystem")
local maps = {} local maps = {}
for map, path in pairs(shortcuts) do for map, path in pairs(shortcuts) do

View File

@ -1,5 +1,9 @@
---@type LazySpec ---@type LazySpec
return { return {
{
"ggandor/flit.nvim",
enabled = false,
},
{ {
"CopilotC-Nvim/CopilotChat.nvim", "CopilotC-Nvim/CopilotChat.nvim",
dependencies = { dependencies = {
@ -12,14 +16,14 @@ return {
}, },
}, },
keys = { keys = {
{ "<leader>acc", "<cmd>CopilotChatToggle<cr>", desc = "Toggle Chat", mode = { "n", "v" } }, { "<leader>acc", "<cmd>CopilotChatToggle<cr>", desc = "Toggle Chat", mode = { "n", "v" } },
{ "<leader>acx", "<cmd>CopilotChatReset<cr>", desc = "Reset Chat", mode = { "n", "v" } }, { "<leader>acx", "<cmd>CopilotChatReset<cr>", desc = "Reset Chat", mode = { "n", "v" } },
{ "<leader>acf", "<cmd>CopilotChatFix<cr>", desc = "Fix Selection", mode = { "v" } }, { "<leader>acf", "<cmd>CopilotChatFix<cr>", desc = "Fix Selection", mode = { "v" } },
{ "<leader>ace", "<cmd>CopilotChatExplain<cr>", desc = "Explain Selection", mode = { "v" } }, { "<leader>ace", "<cmd>CopilotChatExplain<cr>", desc = "Explain Selection", mode = { "v" } },
{ "<leader>acr", "<cmd>CopilotChatExplain<cr>", desc = "Review Selection", mode = { "v" } }, { "<leader>acr", "<cmd>CopilotChatExplain<cr>", desc = "Review Selection", mode = { "v" } },
{ "<leader>aco", "<cmd>CopilotChatOptimize<cr>", desc = "Optimize Selection", mode = { "v" } }, { "<leader>aco", "<cmd>CopilotChatOptimize<cr>", desc = "Optimize Selection", mode = { "v" } },
{ "<leader>acd", "<cmd>CopilotChatDocs<cr>", desc = "Document Selection", mode = { "v" } }, { "<leader>acd", "<cmd>CopilotChatDocs<cr>", desc = "Document Selection", mode = { "v" } },
{ "<leader>act", "<cmd>CopilotChatTests<cr>", desc = "Unittest Selection", mode = { "v" } }, { "<leader>act", "<cmd>CopilotChatTests<cr>", desc = "Unittest Selection", mode = { "v" } },
}, },
opts = { opts = {
window = { window = {
@ -226,13 +230,13 @@ return {
}, },
{ {
"nvim-neo-tree/neo-tree.nvim", "nvim-neo-tree/neo-tree.nvim",
opts = function(_, opts) opts = {
opts.filesystem = { filesystem = {
window = { window = {
mappings = Lib.generate_shortcut_maps(), mappings = Lib.generate_shortcut_maps(),
}, },
} },
end, },
}, },
{ {
"folke/todo-comments.nvim", "folke/todo-comments.nvim",

View File

@ -4,7 +4,7 @@ return {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = { opts = {
auto_install = true, auto_install = true,
ensure_installed = Custom.language.treesitter_install, ensure_installed = Config.language.treesitter_install,
highlight = { highlight = {
additional_vim_regex_highlighting = { "markdown" }, additional_vim_regex_highlighting = { "markdown" },
}, },
@ -13,28 +13,28 @@ return {
{ {
"stevearc/conform.nvim", "stevearc/conform.nvim",
opts = { opts = {
formatters_by_ft = Custom.language.formatters_by_ft, formatters_by_ft = Config.language.formatters_by_ft,
formatters = Custom.language.formatters, formatters = Config.language.formatters,
}, },
}, },
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
opts = { opts = {
servers = Custom.language.lsp, servers = Config.language.lsp,
setup = Custom.language.lsp_setup, setup = Config.language.lsp_setup,
}, },
}, },
{ {
"mfussenegger/nvim-lint", "mfussenegger/nvim-lint",
opts = { opts = {
linters_by_ft = Custom.language.linters_by_ft, linters_by_ft = Config.language.linters_by_ft,
linters = Custom.language.linters, linters = Config.language.linters,
}, },
}, },
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = { opts = {
ensure_installed = Custom.language.mason_install, ensure_installed = Config.language.mason_install,
registries = { registries = {
"github:mason-org/mason-registry", "github:mason-org/mason-registry",
}, },

View File

@ -22,8 +22,8 @@ return {
{ {
"nvimdev/dashboard-nvim", "nvimdev/dashboard-nvim",
opts = function(_, opts) opts = function(_, opts)
local center = Custom.ui.buttons local center = Config.ui.buttons
local banners = Custom.ui.banners local banners = Config.ui.banners
for _, button in ipairs(center) do for _, button in ipairs(center) do
button.desc = button.desc .. string.rep(" ", 43 - #button.desc) button.desc = button.desc .. string.rep(" ", 43 - #button.desc)
button.key_format = " %s" button.key_format = " %s"

View File

@ -2,12 +2,12 @@
zsh=$ZDOTDIR/configs/hashes zsh=$ZDOTDIR/configs/hashes
lf=$XDG_CONFIG_HOME/lf/shortcuts lf=$XDG_CONFIG_HOME/lf/shortcuts
nvim=$XDG_CONFIG_HOME/nvim/lua/custom/shortcuts.lua nvim=$XDG_CONFIG_HOME/nvim/lua/config/shortcuts.lua
clean() { clean() {
echo "# NOTE: Managed by shortcuts script" >"$zsh" echo "# NOTE: Managed by shortcuts script" >"$zsh"
echo "# NOTE: Managed by shortcuts script" >"$lf" echo "# NOTE: Managed by shortcuts script" >"$lf"
printf "%s\n%s\n%s\n" "-- NOTE: Managed by shortcuts script" "---@class custom.shortcuts" "return {" >"$nvim" printf "%s\n%s\n%s\n" "-- NOTE: Managed by shortcuts script" "---@class config.shortcuts" "return {" >"$nvim"
} }
finalize() { finalize() {