1
0
Fork 1

Reafactor

This commit is contained in:
Snoweuph 2024-09-07 20:39:22 +02:00
parent ea9c42e1e4
commit f3710a46b7
Signed by: Snoweuph
GPG key ID: 4014606F050AEF63
108 changed files with 462 additions and 884 deletions

8
.idea/.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

6
.idea/misc.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" default="true" project-jdk-name="22" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/nvim.iml" filepath="$PROJECT_DIR$/.idea/nvim.iml" />
</modules>
</component>
</project>

9
.idea/nvim.iml Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
.idea/vcs.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -1,3 +1,4 @@
require('core.keymap') require('core.keymap')
require('toolchain').init()
require('core.editor') require('core.editor')
require('core.package_manager') require('core.package_manager')

View file

@ -11,9 +11,9 @@ if not vim.loop.fs_stat(lazypath) then
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
local plugins = require('toolchain').plugins local plugins = require('toolchain').get_plugins()
table.insert(plugins, 1, { import = 'editor' }) table.insert(plugins, 1, { import = 'editor' })
require('lazy').setup({ require('lazy').setup({
spec = plugins, spec = plugins
}) })

View file

@ -8,7 +8,7 @@ return {
auto_install = true, auto_install = true,
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },
ensure_installed = require('toolchain').highlighters, ensure_installed = require('toolchain').get_highlighter_autoinstalls(),
}) })
end, end,
} }

View file

@ -14,7 +14,7 @@ return {
}, },
config = function() config = function()
require('mason-lspconfig').setup({ require('mason-lspconfig').setup({
ensure_installed = TOOLCHAIN.lsp_requriemts, ensure_installed = TOOLCHAIN.get_lsp_autoinstalls(),
}) })
end, end,
}, },
@ -26,9 +26,7 @@ return {
local capabilities = require('cmp_nvim_lsp').default_capabilities() local capabilities = require('cmp_nvim_lsp').default_capabilities()
local lspconfig = require('lspconfig') local lspconfig = require('lspconfig')
for _, lsp in ipairs(TOOLCHAIN.language_servers) do TOOLCHAIN.setup_lsps(lspconfig, capabilities)
lsp.setup(lspconfig, capabilities)
end
-- Keybinding -- -- Keybinding --
vim.keymap.set( vim.keymap.set(
@ -67,18 +65,8 @@ return {
-- Setup -- -- Setup --
local null_ls = require('null-ls') local null_ls = require('null-ls')
local null_ls_sources = {}
for _, setup_function in ipairs(TOOLCHAIN.diagnostics) do
local conf = setup_function(null_ls)
if #conf ~= 0 then
for _, _conf in pairs(conf) do
table.insert(null_ls_sources, _conf)
end
end
end
null_ls.setup({ null_ls.setup({
sources = null_ls_sources, sources = TOOLCHAIN.get_null_ls_source(null_ls),
}) })
-- Keybinding -- -- Keybinding --

41
lua/toolchain/config.lua Normal file
View file

@ -0,0 +1,41 @@
local T = require('toolchain')
local M = {}
M.setup = function()
T.add_highlighter_autoinstalls('json', 'xml', 'yaml', 'toml')
T.add_null_ls_module(function(null_ls)
return {
null_ls.builtins.diagnostics.spectral,
--null_ls.builtins.diagnostics.vacuum --Pure Openapi linter
}
end)
T.add_lsp_autoinstalls('jsonls', 'lemminx', 'yamlls', 'taplo')
T.add_lsps(function(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.jsonls.setup(config)
lspconfig.lemminx.setup(config)
lspconfig.yamlls.setup(config)
lspconfig.taplo.setup(config)
end)
T.add_plugins(
{
'folke/lazydev.nvim',
ft = 'lua',
opts = {
library = {},
},
},
{
"folke/neoconf.nvim",
priority = 100,
config = function()
require('neoconf').setup()
end
}
)
end
return M

View file

@ -1,5 +0,0 @@
---@type ToolchainActions
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,4 +0,0 @@
---@type ToolchainDebuggers
return {
plugins = {},
}

View file

@ -1,10 +0,0 @@
---@type ToolchainDiagnostics
return {
plugins = {},
setup = function(null_ls)
return {
null_ls.builtins.diagnostics.spectral,
--null_ls.builtins.diagnostics.vacuum --Pure Openapi linter
}
end,
}

View file

@ -1,5 +0,0 @@
---@type ToolchainFormatters
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,9 +0,0 @@
---@type Toolchain
return {
requirements = require('toolchain.config.requirements'),
language_servers = require('toolchain.config.language_server'),
formatters = require('toolchain.config.formatter'),
actions = require('toolchain.config.actions'),
diagnostics = require('toolchain.config.diagnostics'),
debuggers = require('toolchain.config.debugger'),
}

View file

@ -1,16 +0,0 @@
---@type ToolchainLanguageServers
return {
requirements = {
'jsonls',
'lemminx',
'yamlls',
'taplo',
},
setup = function(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.jsonls.setup(config)
lspconfig.lemminx.setup(config)
lspconfig.yamlls.setup(config)
lspconfig.taplo.setup(config)
end,
}

View file

@ -1,16 +0,0 @@
return {
{
'folke/lazydev.nvim',
ft = 'lua',
opts = {
library = {},
},
},
{
"folke/neoconf.nvim",
priority = 100,
config = function ()
require('neoconf').setup()
end
}
}

View file

@ -1,17 +0,0 @@
---@type ToolchainRequirements
return {
plugins = {
table.unpack(require('toolchain.config.formatter').plugins),
table.unpack(require('toolchain.config.actions').plugins),
table.unpack(require('toolchain.config.diagnostics').plugins),
table.unpack(require('toolchain.config.debugger').plugins),
table.unpack(require('toolchain.config.plugins')),
},
highlighters = {
'json',
'xml',
'yaml',
'toml',
},
language_servers = require('toolchain.config.language_server').requirements,
}

View file

@ -0,0 +1,13 @@
local T = require('toolchain')
local M = {}
M.setup = function()
T.add_highlighter_autoinstalls('sql')
T.add_lsp_autoinstalls('sqlls')
T.add_lsps(function(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.sqlls.setup(config)
end)
end
return M

View file

@ -1,5 +0,0 @@
---@type ToolchainActions
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,4 +0,0 @@
---@type ToolchainDebuggers
return {
plugins = {},
}

View file

@ -1,5 +0,0 @@
---@type ToolchainDiagnostics
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,5 +0,0 @@
---@type ToolchainFormatters
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,9 +0,0 @@
---@type Toolchain
return {
requirements = require('toolchain.database.requirements'),
language_servers = require('toolchain.database.language_server'),
formatters = require('toolchain.database.formatter'),
actions = require('toolchain.database.actions'),
diagnostics = require('toolchain.database.diagnostics'),
debuggers = require('toolchain.database.debugger'),
}

View file

@ -1,10 +0,0 @@
---@type ToolchainLanguageServers
return {
requirements = {
'sqlls',
},
setup = function(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.sqlls.setup(config)
end,
}

View file

@ -1 +0,0 @@
return {}

View file

@ -1,14 +0,0 @@
---@type ToolchainRequirements
return {
plugins = {
table.unpack(require('toolchain.database.formatter').plugins),
table.unpack(require('toolchain.database.actions').plugins),
table.unpack(require('toolchain.database.diagnostics').plugins),
table.unpack(require('toolchain.database.debugger').plugins),
table.unpack(require('toolchain.database.plugins')),
},
highlighters = {
'sql',
},
language_servers = require('toolchain.database.language_server').requirements,
}

View file

@ -0,0 +1,14 @@
local T = require('toolchain')
local M = {}
M.setup = function()
T.add_highlighter_autoinstalls('svelte', 'vue')
T.add_lsp_autoinstalls('svelte', 'volar')
T.add_lsps(function(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.svelte.setup(config)
lspconfig.volar.setup(config)
end)
end
return M

View file

@ -1,5 +0,0 @@
---@type ToolchainActions
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,4 +0,0 @@
---@type ToolchainDebuggers
return {
plugins = {},
}

View file

@ -1,5 +0,0 @@
---@type ToolchainDiagnostics
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,5 +0,0 @@
---@type ToolchainFormatters
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,9 +0,0 @@
---@type Toolchain
return {
requirements = require('toolchain.frontend.requirements'),
language_servers = require('toolchain.frontend.language_server'),
formatters = require('toolchain.frontend.formatter'),
actions = require('toolchain.frontend.actions'),
diagnostics = require('toolchain.frontend.diagnostics'),
debuggers = require('toolchain.frontend.debugger'),
}

View file

@ -1,12 +0,0 @@
---@type ToolchainLanguageServers
return {
requirements = {
'svelte',
'volar',
},
setup = function(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.svelte.setup(config)
lspconfig.volar.setup(config)
end,
}

View file

@ -1 +0,0 @@
return {}

View file

@ -1,16 +0,0 @@
---@type ToolchainRequirements
return {
plugins = {
table.unpack(require('toolchain.frontend.formatter').plugins),
table.unpack(require('toolchain.frontend.actions').plugins),
table.unpack(require('toolchain.frontend.diagnostics').plugins),
table.unpack(require('toolchain.frontend.debugger').plugins),
table.unpack(require('toolchain.frontend.plugins')),
},
highlighters = {
'svelte',
'vue',
},
language_servers = require('toolchain.frontend.language_server').requirements,
}

13
lua/toolchain/generic.lua Normal file
View file

@ -0,0 +1,13 @@
local T = require('toolchain')
local M = {}
M.setup = function()
T.add_null_ls_module(function(null_ls)
return {
-- Actions
null_ls.builtins.code_actions.refactoring,
}
end)
end
return M

View file

@ -1,9 +0,0 @@
---@type ToolchainActions
return {
plugins = {},
setup = function(null_ls)
return {
null_ls.builtins.code_actions.refactoring,
}
end,
}

View file

@ -1,4 +0,0 @@
---@type ToolchainDebuggers
return {
plugins = {},
}

View file

@ -1,5 +0,0 @@
---@type ToolchainDiagnostics
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,5 +0,0 @@
---@type ToolchainFormatters
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,9 +0,0 @@
---@type Toolchain
return {
requirements = require('toolchain.generic.requirements'),
language_servers = require('toolchain.generic.language_server'),
formatters = require('toolchain.generic.formatter'),
actions = require('toolchain.generic.actions'),
diagnostics = require('toolchain.generic.diagnostics'),
debuggers = require('toolchain.generic.debugger'),
}

View file

@ -1,5 +0,0 @@
---@type ToolchainLanguageServers
return {
requirements = {},
setup = function(_lspgeneric, _capabilities) end,
}

View file

@ -1 +0,0 @@
return {}

View file

@ -1,12 +0,0 @@
---@type ToolchainRequirements
return {
plugins = {
table.unpack(require('toolchain.generic.formatter').plugins),
table.unpack(require('toolchain.generic.actions').plugins),
table.unpack(require('toolchain.generic.diagnostics').plugins),
table.unpack(require('toolchain.generic.debugger').plugins),
table.unpack(require('toolchain.generic.plugins')),
},
highlighters = {},
language_servers = require('toolchain.generic.language_server').requirements,
}

47
lua/toolchain/git.lua Normal file
View file

@ -0,0 +1,47 @@
local T = require('toolchain')
local M = {}
M.setup = function()
T.add_highlighter_autoinstalls('gitcommit', 'gitignore', 'gitattributes', 'git_rebase', 'git_config')
T.add_plugins(
{
'tpope/vim-fugitive',
},
{
'lewis6991/gitsigns.nvim',
config = function()
-- Setup --
require('gitsigns').setup()
-- Keybinding --
vim.keymap.set(
'n',
'<leader>gh',
':Gitsigns preview_hunk_inline<CR>',
{ desc = 'Toggle Inline Git Diff' }
)
vim.keymap.set(
'n',
'<leader>gb',
':Gitsigns toggle_current_line_blame<CR>',
{ desc = 'Toggle Inline Git Blame' }
)
vim.keymap.set(
'n',
'<leader>go',
':Git <CR>',
{ desc = 'Open Git' }
)
end,
},
{
'moyiz/git-dev.nvim',
lazy = true,
cmd = { 'GitDevOpen', 'GitDevCleanAll' },
opts = {},
}
)
end
return M

View file

@ -1,5 +0,0 @@
---@type ToolchainActions
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,4 +0,0 @@
---@type ToolchainDebuggers
return {
plugins = {},
}

View file

@ -1,5 +0,0 @@
---@type ToolchainDiagnostics
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,5 +0,0 @@
---@type ToolchainFormatters
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,9 +0,0 @@
---@type Toolchain
return {
requirements = require('toolchain.git.requirements'),
language_servers = require('toolchain.git.language_server'),
formatters = require('toolchain.git.formatter'),
actions = require('toolchain.git.actions'),
diagnostics = require('toolchain.git.diagnostics'),
debuggers = require('toolchain.git.debugger'),
}

View file

@ -1,5 +0,0 @@
---@type ToolchainLanguageServers
return {
requirements = {},
setup = function(_lspconfig, _capabilities) end,
}

View file

@ -1,38 +0,0 @@
return {
{
'tpope/vim-fugitive',
},
{
'lewis6991/gitsigns.nvim',
config = function()
-- Setup --
require('gitsigns').setup()
-- Keybinding --
vim.keymap.set(
'n',
'<leader>gh',
':Gitsigns preview_hunk_inline<CR>',
{ desc = 'Toggle Inline Git Diff' }
)
vim.keymap.set(
'n',
'<leader>gb',
':Gitsigns toggle_current_line_blame<CR>',
{ desc = 'Toggle Inline Git Blame' }
)
vim.keymap.set(
'n',
'<leader>go',
':Git <CR>',
{ desc = 'Open Git' }
)
end,
},
{
'moyiz/git-dev.nvim',
lazy = true,
cmd = { 'GitDevOpen', 'GitDevCleanAll' },
opts = {},
},
}

View file

@ -1,18 +0,0 @@
---@type ToolchainRequirements
return {
plugins = {
table.unpack(require('toolchain.git.formatter').plugins),
table.unpack(require('toolchain.git.actions').plugins),
table.unpack(require('toolchain.git.diagnostics').plugins),
table.unpack(require('toolchain.git.debugger').plugins),
table.unpack(require('toolchain.git.plugins')),
},
highlighters = {
'gitcommit',
'gitignore',
'gitattributes',
'git_rebase',
'git_config',
},
language_servers = require('toolchain.git.language_server').requirements,
}

38
lua/toolchain/go.lua Normal file
View file

@ -0,0 +1,38 @@
local T = require('toolchain')
local M = {}
M.setup = function()
T.add_highlighter_autoinstalls('go', 'gomod', 'gosum', 'gotmpl')
T.add_null_ls_module(function(null_ls)
return {
-- Actions
null_ls.builtins.code_actions.gomodifytags,
null_ls.builtins.code_actions.impl,
-- Diagnostics
null_ls.builtins.diagnostics.golangci_lint,
null_ls.builtins.diagnostics.staticcheck,
-- Formatter
null_ls.builtins.formatting.gofumpt,
}
end)
T.add_lsp_autoinstalls('gopls')
T.add_lsps(function(lspconfig, capabilities)
lspconfig.gopls.setup({ capabilities = capabilities })
end)
T.add_plugins({
'leoluz/nvim-dap-go',
config = function()
local dir = require('util.finder').find_project_dir(
'go.mod',
3,
{ 'src', 'app', 'pkg' },
{ 'test' },
true
)
require('dap-go').setup({ delve = { cwd = dir } })
end,
})
end
return M

View file

@ -1,10 +0,0 @@
---@type ToolchainActions
return {
plugins = {},
setup = function(null_ls)
return {
null_ls.builtins.code_actions.gomodifytags,
null_ls.builtins.code_actions.impl,
}
end,
}

View file

@ -1,18 +0,0 @@
---@type ToolchainDebuggers
return {
plugins = {
{
'leoluz/nvim-dap-go',
config = function()
local dir = require('util.finder').find_project_dir(
'go.mod',
3,
{ 'src', 'app', 'pkg' },
{ 'test' },
true
)
require('dap-go').setup({ delve = { cwd = dir } })
end,
},
},
}

View file

@ -1,10 +0,0 @@
---@type ToolchainDiagnostics
return {
plugins = {},
setup = function(null_ls)
return {
null_ls.builtins.diagnostics.golangci_lint,
null_ls.builtins.diagnostics.staticcheck,
}
end,
}

View file

@ -1,9 +0,0 @@
---@type ToolchainFormatters
return {
plugins = {},
setup = function(null_ls)
return {
null_ls.builtins.formatting.gofumpt,
}
end,
}

View file

@ -1,9 +0,0 @@
---@type Toolchain
return {
requirements = require('toolchain.go.requirements'),
language_servers = require('toolchain.go.language_server'),
formatters = require('toolchain.go.formatter'),
actions = require('toolchain.go.actions'),
diagnostics = require('toolchain.go.diagnostics'),
debuggers = require('toolchain.go.debugger'),
}

View file

@ -1,9 +0,0 @@
---@type ToolchainLanguageServers
return {
requirements = {
'gopls',
},
setup = function(lspconfig, capabilities)
lspconfig.gopls.setup({ capabilities = capabilities })
end,
}

View file

@ -1 +0,0 @@
return {}

View file

@ -1,17 +0,0 @@
---@type ToolchainRequirements
return {
plugins = {
table.unpack(require('toolchain.go.formatter').plugins),
table.unpack(require('toolchain.go.actions').plugins),
table.unpack(require('toolchain.go.diagnostics').plugins),
table.unpack(require('toolchain.go.debugger').plugins),
table.unpack(require('toolchain.go.plugins')),
},
highlighters = {
'go',
'gomod',
'gosum',
'gotmpl',
},
language_servers = require('toolchain.go.language_server').requirements,
}

View file

@ -1,106 +1,113 @@
local TOOLCHAINS = {} local TOOLCHAINS = {}
local config = require('toolchain.config') ------------
local database = require('toolchain.database') -- Plugins -
local frontend = require('toolchain.frontend') ------------
local generic = require('toolchain.generic')
local git = require('toolchain.git')
local go = require('toolchain.go')
local lua = require('toolchain.lua')
local php = require('toolchain.php')
local scripts = require('toolchain.scripts')
local text = require('toolchain.text')
local web = require('toolchain.web')
TOOLCHAINS.plugins = { local plugins = {}
table.unpack(config.requirements.plugins),
table.unpack(database.requirements.plugins),
table.unpack(frontend.requirements.plugins),
table.unpack(generic.requirements.plugins),
table.unpack(git.requirements.plugins),
table.unpack(go.requirements.plugins),
table.unpack(lua.requirements.plugins),
table.unpack(php.requirements.plugins),
table.unpack(scripts.requirements.plugins),
table.unpack(text.requirements.plugins),
table.unpack(web.requirements.plugins),
}
TOOLCHAINS.highlighters = { --- @param ... LazySpec
table.unpack(config.requirements.highlighters), TOOLCHAINS.add_plugins = function(...)
table.unpack(database.requirements.highlighters), for _, spec in ipairs({...}) do
table.unpack(frontend.requirements.highlighters), table.insert(plugins, spec)
table.unpack(generic.requirements.highlighters), end
table.unpack(git.requirements.highlighters), end
table.unpack(go.requirements.highlighters),
table.unpack(lua.requirements.highlighters),
table.unpack(php.requirements.highlighters),
table.unpack(scripts.requirements.highlighters),
table.unpack(text.requirements.highlighters),
table.unpack(web.requirements.highlighters),
}
TOOLCHAINS.language_servers = { TOOLCHAINS.get_plugins = function()
table.unpack(config.language_servers), return plugins
table.unpack(database.language_servers), end
table.unpack(frontend.language_servers), ---------
table.unpack(generic.language_servers), -- LSPs -
table.unpack(git.language_servers), ---------
table.unpack(go.language_servers), local lsp_autoinstalls = {}
table.unpack(lua.language_servers), local lsp_setups = {}
table.unpack(php.language_servers),
table.unpack(scripts.language_servers),
table.unpack(text.language_servers),
table.unpack(web.language_servers),
}
TOOLCHAINS.diagnostics = { --- @param ... string
table.unpack(config.diagnostics), TOOLCHAINS.add_lsp_autoinstalls = function(...)
table.unpack(database.diagnostics), for _, lsp in ipairs({...}) do
table.unpack(frontend.diagnostics), table.insert(lsp_autoinstalls, lsp)
table.unpack(generic.diagnostics), end
table.unpack(git.diagnostics), end
table.unpack(go.diagnostics),
table.unpack(lua.diagnostics),
table.unpack(php.diagnostics),
table.unpack(scripts.diagnostics),
table.unpack(text.diagnostics),
table.unpack(web.diagnostics),
}
TOOLCHAINS.get_lsp_autoinstalls = function()
return lsp_autoinstalls
end
--- @param setup SetupLSPs
TOOLCHAINS.add_lsps = function(setup)
table.insert(lsp_setups, setup)
end
--- @param lspconfig any
--- @param capabilities any
TOOLCHAINS.setup_lsps = function(lspconfig, capabilities)
for _, setup in ipairs(lsp_setups) do
setup(lspconfig, capabilities)
end
end
------------
-- Null ls -
------------
local null_ls_setups = {}
--- @param setup SetupNullLsModule
TOOLCHAINS.add_null_ls_module = function(setup)
table.insert(null_ls_setups, setup)
end
TOOLCHAINS.get_null_ls_source = function(null_ls)
local null_ls_sources = {}
for _, setup_function in ipairs(null_ls_setups) do
local conf = setup_function(null_ls)
if #conf ~= 0 then
for _, _conf in pairs(conf) do
table.insert(null_ls_sources, _conf)
end
end
end
return null_ls_sources
end
----------------
-- Highlighter -
----------------
local highlighter_autoinstalls = {}
--- @param ... string
TOOLCHAINS.add_highlighter_autoinstalls = function(...)
for _, highlighter in ipairs({...}) do
table.insert(highlighter_autoinstalls, highlighter)
end
end
TOOLCHAINS.get_highlighter_autoinstalls = function()
return highlighter_autoinstalls
end
----------------
-- Init -
----------------
TOOLCHAINS.init = function()
require('toolchain.config').setup()
require('toolchain.database').setup()
require('toolchain.frontend').setup()
require('toolchain.generic').setup()
require('toolchain.git').setup()
require('toolchain.go').setup()
require('toolchain.lua').setup()
require('toolchain.php').setup()
require('toolchain.scripts').setup()
require('toolchain.text').setup()
require('toolchain.web').setup()
end
return TOOLCHAINS return TOOLCHAINS
--Type Definitions ---------------------
-- Type Definitions -
---@class Toolchain ---------------------
---@field requirements ToolchainRequirements ---@alias SetupLSPs fun(lspconfig:any, capabilities: any)
---@field formatters ToolchainFormatters ---@alias SetupNullLsModule fun(null_ls: any):table
---@field language_servers ToolchainLanguageServers
---@field actions ToolchainActions
---@field diagnostics ToolchainDiagnostics
---@field debuggers ToolchainDebuggers
---@class ToolchainRequirements
---@field plugins LazySpec[]
---@field highlighters table
---@field language_servers table
---@class ToolchainLanguageServers
---@field requirements string[]
---@field setup fun(lspconfig:any, capabilities: any)
---@class ToolchainFormatters
---@field plugins LazySpec[]
---@field setup fun(null_ls: any):table
---@class ToolchainActions
---@field plugins LazySpec[]
---@field setup fun(null_ls: any):table
---@class ToolchainDiagnostics
---@field plugins LazySpec[]
---@field setup fun(null_ls: any):table
---@class ToolchainDebuggers
---@field plugins LazySpec[]

31
lua/toolchain/lua.lua Normal file
View file

@ -0,0 +1,31 @@
local T = require('toolchain')
local M = {}
M.setup = function()
T.add_highlighter_autoinstalls('lua','luadoc')
T.add_null_ls_module(function(null_ls)
return {
-- Diagnostics
null_ls.builtins.diagnostics.selene,
-- Formatter
null_ls.builtins.formatting.stylua,
}
end)
T.add_lsp_autoinstalls('lua_ls')
T.add_lsps(function(lspconfig, capabilities)
lspconfig.lua_ls.setup({
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
globals = { 'vim' },
},
},
},
})
end)
end
return M

View file

@ -1,5 +0,0 @@
---@type ToolchainActions
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,4 +0,0 @@
---@type ToolchainDebuggers
return {
plugins = {},
}

View file

@ -1,9 +0,0 @@
---@type ToolchainDiagnostics
return {
plugins = {},
setup = function(null_ls)
return {
null_ls.builtins.diagnostics.selene,
}
end,
}

View file

@ -1,9 +0,0 @@
---@type ToolchainFormatters
return {
plugins = {},
setup = function(null_ls)
return {
null_ls.builtins.formatting.stylua,
}
end,
}

View file

@ -1,9 +0,0 @@
---@type Toolchain
return {
requirements = require('toolchain.lua.requirements'),
language_servers = require('toolchain.lua.language_server'),
formatters = require('toolchain.lua.formatter'),
actions = require('toolchain.lua.actions'),
diagnostics = require('toolchain.lua.diagnostics'),
debuggers = require('toolchain.lua.debugger'),
}

View file

@ -1,18 +0,0 @@
---@type ToolchainLanguageServers
return {
requirements = {
'lua_ls',
},
setup = function(lspconfig, capabilities)
lspconfig.lua_ls.setup({
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
globals = { 'vim' },
},
},
},
})
end,
}

View file

@ -1 +0,0 @@
return {}

View file

@ -1,15 +0,0 @@
---@type ToolchainRequirements
return {
plugins = {
table.unpack(require('toolchain.lua.formatter').plugins),
table.unpack(require('toolchain.lua.actions').plugins),
table.unpack(require('toolchain.lua.diagnostics').plugins),
table.unpack(require('toolchain.lua.debugger').plugins),
table.unpack(require('toolchain.lua.plugins')),
},
highlighters = {
'lua',
'luadoc',
},
language_servers = require('toolchain.lua.language_server').requirements,
}

29
lua/toolchain/php.lua Normal file
View file

@ -0,0 +1,29 @@
local T = require('toolchain')
local M = {}
M.setup = function()
T.add_highlighter_autoinstalls('php', 'phpdoc', 'twig')
T.add_null_ls_module(function(null_ls)
return {
-- Diagnostics
null_ls.builtins.diagnostics.phpstan,
null_ls.builtins.diagnostics.phpcs,
null_ls.builtins.diagnostics.twigcs,
-- Formatter
null_ls.builtins.formatting.phpcsfixer.with({
prefer_local = 'vendor/bin/php-cs-fixer',
args = { 'fix', '--allow-risky=yes', '$FILENAME' },
}),
}
end)
T.add_lsp_autoinstalls('phpactor', 'twiggy_language_server', 'stimulus_ls')
T.add_lsps(function(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.phpactor.setup(config)
lspconfig.stimulus_ls.setup(config)
end)
end
return M

View file

@ -1,5 +0,0 @@
---@type ToolchainActions
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,4 +0,0 @@
---@type ToolchainDebuggers
return {
plugins = {},
}

View file

@ -1,11 +0,0 @@
---@type ToolchainDiagnostics
return {
plugins = {},
setup = function(null_ls)
return {
null_ls.builtins.diagnostics.phpstan,
null_ls.builtins.diagnostics.phpcs,
null_ls.builtins.diagnostics.twigcs,
}
end,
}

View file

@ -1,12 +0,0 @@
---@type ToolchainFormatters
return {
plugins = {},
setup = function(null_ls)
return {
null_ls.builtins.formatting.phpcsfixer.with({
prefer_local = 'vendor/bin/php-cs-fixer',
args = { 'fix', '--allow-risky=yes', '$FILENAME' },
}),
}
end,
}

View file

@ -1,9 +0,0 @@
---@type Toolchain
return {
requirements = require('toolchain.php.requirements'),
language_servers = require('toolchain.php.language_server'),
formatters = require('toolchain.php.formatter'),
actions = require('toolchain.php.actions'),
diagnostics = require('toolchain.php.diagnostics'),
debuggers = require('toolchain.php.debugger'),
}

View file

@ -1,13 +0,0 @@
---@type ToolchainLanguageServers
return {
requirements = {
'phpactor',
'twiggy_language_server',
'stimulus_ls',
},
setup = function(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.phpactor.setup(config)
lspconfig.stimulus_ls.setup(config)
end,
}

View file

@ -1 +0,0 @@
return {}

View file

@ -1,16 +0,0 @@
---@type ToolchainRequirements
return {
plugins = {
table.unpack(require('toolchain.php.formatter').plugins),
table.unpack(require('toolchain.php.actions').plugins),
table.unpack(require('toolchain.php.diagnostics').plugins),
table.unpack(require('toolchain.php.debugger').plugins),
table.unpack(require('toolchain.php.plugins')),
},
highlighters = {
'php',
'phpdoc',
'twig',
},
language_servers = require('toolchain.php.language_server').requirements,
}

26
lua/toolchain/scripts.lua Normal file
View file

@ -0,0 +1,26 @@
local T = require('toolchain')
local M = {}
M.setup = function()
T.add_highlighter_autoinstalls('bash', 'dockerfile', 'make', 'just')
T.add_null_ls_module(function(null_ls)
return {
-- Diagnostics
null_ls.builtins.diagnostics.actionlint,
null_ls.builtins.diagnostics.checkmake,
null_ls.builtins.diagnostics.dotenv_linter,
-- Formatter
null_ls.builtins.formatting.shfmt,
null_ls.builtins.formatting.shellharden,
}
end)
T.add_lsp_autoinstalls('bashls')
T.add_lsps(function(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.bashls.setup(config)
end)
end
return M

View file

@ -1,5 +0,0 @@
---@type ToolchainActions
return {
plugins = {},
setup = function(_null_ls) return {} end,
}

View file

@ -1,4 +0,0 @@
---@type ToolchainDebuggers
return {
plugins = {},
}

View file

@ -1,11 +0,0 @@
---@type ToolchainDiagnostics
return {
plugins = {},
setup = function(null_ls)
return {
null_ls.builtins.diagnostics.actionlint,
null_ls.builtins.diagnostics.checkmake,
null_ls.builtins.diagnostics.dotenv_linter,
}
end,
}

View file

@ -1,10 +0,0 @@
---@type ToolchainFormatters
return {
plugins = {},
setup = function(null_ls)
return {
null_ls.builtins.formatting.shfmt,
null_ls.builtins.formatting.shellharden,
}
end,
}

View file

@ -1,9 +0,0 @@
---@type Toolchain
return {
requirements = require('toolchain.scripts.requirements'),
language_servers = require('toolchain.scripts.language_server'),
formatters = require('toolchain.scripts.formatter'),
actions = require('toolchain.scripts.actions'),
diagnostics = require('toolchain.scripts.diagnostics'),
debuggers = require('toolchain.scripts.debugger'),
}

View file

@ -1,10 +0,0 @@
---@type ToolchainLanguageServers
return {
requirements = {
'bashls',
},
setup = function(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.bashls.setup(config)
end,
}

View file

@ -1 +0,0 @@
return {}

View file

@ -1,17 +0,0 @@
---@type ToolchainRequirements
return {
plugins = {
table.unpack(require('toolchain.scripts.formatter').plugins),
table.unpack(require('toolchain.scripts.actions').plugins),
table.unpack(require('toolchain.scripts.diagnostics').plugins),
table.unpack(require('toolchain.scripts.debugger').plugins),
table.unpack(require('toolchain.scripts.plugins')),
},
highlighters = {
'bash',
'make',
'just',
'dockerfile',
},
language_servers = require('toolchain.scripts.language_server').requirements,
}

View file

@ -1,5 +1,30 @@
local T = require('toolchain')
local M = {}
M.setup = function()
T.add_highlighter_autoinstalls('markdown')
T.add_null_ls_module(function(null_ls)
return { return {
{ -- Actions
null_ls.builtins.code_actions.proselint,
-- Diagnostics
null_ls.builtins.diagnostics.alex,
null_ls.builtins.diagnostics.codespell,
null_ls.builtins.diagnostics.trail_space,
-- Formatter
null_ls.builtins.diagnostics.markdownlint,
}
end)
T.add_lsp_autoinstalls('marksman')
T.add_lsps(function(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.marksman.setup(config)
end)
T.add_plugins({
'mrjones2014/mdpreview.nvim', 'mrjones2014/mdpreview.nvim',
ft = 'markdown', ft = 'markdown',
dependencies = { dependencies = {
@ -32,5 +57,7 @@ return {
{ desc = 'Show Markdown Preview' } { desc = 'Show Markdown Preview' }
) )
end, end,
}, })
} end
return M

View file

@ -1,9 +0,0 @@
---@type ToolchainActions
return {
plugins = {},
setup = function(null_ls)
return {
null_ls.builtins.code_actions.proselint,
}
end,
}

View file

@ -1,4 +0,0 @@
---@type ToolchainDebuggers
return {
plugins = {},
}

View file

@ -1,11 +0,0 @@
---@type ToolchainDiagnostics
return {
plugins = {},
setup = function(null_ls)
return {
null_ls.builtins.diagnostics.alex,
null_ls.builtins.diagnostics.codespell,
null_ls.builtins.diagnostics.trail_space,
}
end,
}

View file

@ -1,9 +0,0 @@
---@type ToolchainFormatters
return {
plugins = {},
setup = function(null_ls)
return {
null_ls.builtins.diagnostics.markdownlint,
}
end,
}

View file

@ -1,9 +0,0 @@
---@type Toolchain
return {
requirements = require('toolchain.text.requirements'),
language_servers = require('toolchain.text.language_server'),
formatters = require('toolchain.text.formatter'),
actions = require('toolchain.text.actions'),
diagnostics = require('toolchain.text.diagnostics'),
debuggers = require('toolchain.text.debugger'),
}

View file

@ -1,10 +0,0 @@
---@type ToolchainLanguageServers
return {
requirements = {
'marksman',
},
setup = function(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.marksman.setup(config)
end,
}

View file

@ -1,14 +0,0 @@
---@type ToolchainRequirements
return {
plugins = {
table.unpack(require('toolchain.text.formatter').plugins),
table.unpack(require('toolchain.text.actions').plugins),
table.unpack(require('toolchain.text.diagnostics').plugins),
table.unpack(require('toolchain.text.debugger').plugins),
table.unpack(require('toolchain.text.plugins')),
},
highlighters = {
'markdown',
},
language_servers = require('toolchain.text.language_server').requirements,
}

31
lua/toolchain/web.lua Normal file
View file

@ -0,0 +1,31 @@
local T = require('toolchain')
local M = {}
M.setup = function()
T.add_highlighter_autoinstalls('html', 'css', 'scss', 'javascript', 'typescript')
T.add_null_ls_module(function(null_ls)
return {
-- Diagnostics
null_ls.builtins.diagnostics.stylelint,
-- Formatter
null_ls.builtins.formatting.prettier.with({
command = 'prettierd',
}),
}
end)
T.add_lsp_autoinstalls('html', 'emmet_ls', 'cssls', 'tailwindcss', 'eslint', 'tsserver')
T.add_lsps(function(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.html.setup(config)
lspconfig.emmet_ls.setup(config)
lspconfig.cssls.setup(config)
lspconfig.tailwindcss.setup(config)
lspconfig.tsserver.setup(config)
lspconfig.eslint.setup(config)
end)
end
return M

Some files were not shown because too many files have changed in this diff Show more