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 65d6e269fb
13 changed files with 58 additions and 53 deletions

View File

@ -1,4 +1,4 @@
_G.Custom = require("custom")
_G.Config = require("config")
_G.Lib = require("lib")
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
---@class custom.language
---@class config.language
local M = {}
---@type table<string, conform.FormatterUnit>
M.formatters_by_ft = {
lua = { "stylua" },
sh = { "shfmt" },
python = { "black" },
}
---@type table<string, conform.FormatterConfigOverride|fun(bufnr: integer): nil|conform.FormatterConfigOverride>
@ -158,16 +159,10 @@ M.lsp_setup = {
LazyVim.lsp.on_attach(function(client, _)
if client.name == "ruff_lsp" then
client.server_capabilities.hoverProvider = false
client.server_capabilities.renameProvider = false
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()
return true
end,

View File

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

View File

@ -0,0 +1,6 @@
---@class config.secrets
return {
sourcery = "user_qHOjfe6w58Xeuw7_wij5zh7CCRGzPXQKJE7nJwiYlcnAQ1_mGN4AKSL9q1I",
intelephense = "00QRJLHV4WVNB1E",
openai = "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",
}

View File

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

View File

@ -1,4 +1,4 @@
---@class custom.ui
---@class config.ui
local M = {}
---@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>
function M.generate_shortcut_maps()
local shortcuts = Custom.shortcuts
local shortcuts = Config.shortcuts
local fs = require("neo-tree.sources.filesystem")
local maps = {}
for map, path in pairs(shortcuts) do

View File

@ -1,5 +1,9 @@
---@type LazySpec
return {
{
"ggandor/flit.nvim",
enabled = false,
},
{
"CopilotC-Nvim/CopilotChat.nvim",
dependencies = {
@ -226,13 +230,13 @@ return {
},
{
"nvim-neo-tree/neo-tree.nvim",
opts = function(_, opts)
opts.filesystem = {
opts = {
filesystem = {
window = {
mappings = Lib.generate_shortcut_maps(),
},
}
end,
},
},
},
{
"folke/todo-comments.nvim",

View File

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

View File

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

View File

@ -2,12 +2,12 @@
zsh=$ZDOTDIR/configs/hashes
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() {
echo "# NOTE: Managed by shortcuts script" >"$zsh"
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() {