Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions lua/doom/core/doom_global.lua
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,8 @@ doom = {

-- Logging level
-- Set Doom logging level
-- Available levels:
-- · trace
-- · debug
-- · info
-- · warn
-- · error
-- · fatal
-- @default = 'info'
-- @default = "info"
--- @type "trace"|"debug"|"info"|"warn"|"error"|"fatal"
logging = "info",

-- Default colorscheme
Expand Down
14 changes: 10 additions & 4 deletions lua/doom/core/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,8 @@ end
-- Set the indent and tab related numbers.
-- Negative numbers mean tabstop -- Really though? Tabs?
functions.set_indent = function()
local indent = tonumber(
vim.fn.input("Set indent (>0 uses spaces, <0 uses tabs, 0 uses vim defaults): ")
)
local indent =
tonumber(vim.fn.input("Set indent (>0 uses spaces, <0 uses tabs, 0 uses vim defaults): "))
if not indent then
indent = -8
end
Expand Down Expand Up @@ -257,7 +256,7 @@ end
functions.nuke = function(target)
if target == nil or #target == 0 then
vim.notify(
"Warning, this command deletes packer caches and causes a re-install of doom-nvim on next launch.\n\n :DoomNuke `plugins`|`cache`|`all`. \n\t `cache` - Clear packer_compiled.lua\n\t `plugins` - Clear all installed plugins\n\t `all` - Delete all of the above."
"Warning, this command deletes packer caches and causes a re-install of doom-nvim on next launch.\n\n :DoomNuke plugins|cache|mason|all. \n\t `cache` - Clear packer_compiled.lua\n\t `plugins` - Clear all installed plugins\n\t `mason` - Clear all Mason.nvim packages\n\t `all` - Delete all of the above."
)
return
end
Expand All @@ -276,6 +275,13 @@ functions.nuke = function(target)
fs.rm_dir(plugin_dir)
log.info("DoomNuke: Deleting packer plugins. Doom-nvim will re-install on next launch.")
end

if target == "all" or target == "mason" then
local util = require("packer.util")
local mason_dir = util.join_paths(vim.fn.stdpath("data"), "mason")
fs.rm_dir(mason_dir)
log.info("DoomNuke: Deleting mason packages")
end
end

return functions
7 changes: 5 additions & 2 deletions lua/doom/modules/core/doom/init.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local system = require("doom.core.system")

local required = {}

required.settings = {
Expand Down Expand Up @@ -154,6 +152,11 @@ required.binds = function()
("<cmd>e %s<CR>"):format(require("doom.core.modules").source),
name = "Edit modules",
},
{
"d",
require('doom.core.functions').open_docs,
name = "Open documentation",
},
{ "l", "<cmd>DoomReload<CR>", name = "Reload config" },
{ "r", "<cmd>DoomRollback<CR>", name = "Rollback" },
{ "R", "<cmd>DoomReport<CR>", name = "Report issue" },
Expand Down
44 changes: 10 additions & 34 deletions lua/doom/modules/features/auto_install/init.lua
Original file line number Diff line number Diff line change
@@ -1,45 +1,21 @@
--- Auto installer module
--- Most logic for this module is inside of `lua/doom/modules/langs/utils`
local auto_install = {}

auto_install.settings = {
lsp_dir = nil, -- Change to a custom path such as `vim.fn.stdpath("data") .. "/lsp-install"`
dap_dir = nil, -- Change to a custom path such as `vim.fn.stdpath("data") .. "/dap-install"`
}

local is_module_enabled = require("doom.utils").is_module_enabled

auto_install.packages = {
["DAPInstall.nvim"] = {
"Pocco81/DAPInstall.nvim",
commit = "24923c3819a450a772bb8f675926d530e829665f",
-- after = "nvim-dap",
cmd = {
"DIInstall",
"DIList",
"DIUninstall",
},
disabled = not is_module_enabled("features", "dap"),
module = "dap-install",
disable = true,
["mason.nvim"] = {
"williamboman/mason.nvim",
commit = "75860d253f9e66d08c9289dc43fae790882eb136",
},
["nvim-lsp-installer"] = {
"williamboman/nvim-lsp-installer",
commit = "23820a878a5c2415bfd3b971d1fe3c79e4dd6763",
-- disabled = not is_module_enabled("features", "lsp"),
["mason-lspconfig"] = {
"williamboman/mason-lspconfig",
commit = "b70dedab5ceb5f3f84c6bc9ceea013292a14f8dc",
},
}

auto_install.configs = {}
auto_install.configs["nvim-lsp-installer"] = function()
local lsp_installer = require("nvim-lsp-installer")
lsp_installer.settings({
install_root_dir = doom.features.auto_install.settings.lsp_dir,
})
end
auto_install.configs["DAPInstall.nvim"] = function()
local dap_install = require("dap-install")
dap_install.setup({
installation_path = doom.features.auto_install.settings.dap_dir,
})
auto_install.configs["mason.nvim"] = function()
require("mason").setup()
end

return auto_install
2 changes: 1 addition & 1 deletion lua/doom/modules/features/dashboard/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ dashboard.configs["dashboard-nvim"] = function()
doom.features.dashboard.settings.entries.a = {
icon = " ",
desc = "Load Last Session ",
shortcut = "SPC s r",
shortcut = "SPC q r",
action = "lua require('persistence').load({ last = true })",
}
end
Expand Down
71 changes: 57 additions & 14 deletions lua/doom/modules/features/statusline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ local statusline = {}

statusline.settings = {}

statusline.state = {}
statusline.state.installing_mason_packages = {}
--- Pushes a mason package to be shown in the statusline
---@param name string Name of the package
statusline.state.start_mason_package = function(name)
statusline.state.finish_mason_package(name)
table.insert(statusline.state.installing_mason_packages, name)
end
--- Removes a mason package from being shown in the statusline
---@param name string Name of the package
statusline.state.finish_mason_package = function(name)
local packages = statusline.state.installing_mason_packages
statusline.state.installing_mason_packages = vim.tbl_filter(function(val)
return val ~= name
end, packages)
end

statusline._safe_get_highlight = function(...)
for _, hlname in ipairs({ ... }) do
if vim.fn.hlexists(hlname) == 1 then
Expand Down Expand Up @@ -142,7 +159,7 @@ end
statusline.packages = {
["heirline.nvim"] = {
"rebelot/heirline.nvim",
commit = "9af77c2531a8e10abebf45817e675ecd1966db02",
commit = "19cab76f52710ec67bd8829cbc96d0c322963090",
},
}

Expand Down Expand Up @@ -325,23 +342,47 @@ statusline.configs["heirline.nvim"] = function()
unpack(FileFlags) -- A small optimisation, since their parent does nothing
)

local LSPActive = {
condition = conditions.lsp_attached,
-- Mason LSP indicator, shows when a package is being installed
-- Integrates with the use_mason_package utility function in langs/utils.lua
local MasonStatusElement = {
condition = function()
return #doom.features.statusline.state.installing_mason_packages > 0
end,
provider = function()
local installing_mason_packages = doom.features.statusline.state.installing_mason_packages
return (
("Installing %s... "):format(table.concat(installing_mason_packages, ", "))
)
end,
on_click = {
callback = function()
vim.cmd("Mason")
end,
name = "mason",
},
hl = { fg = colors.special },
}

-- You can keep it simple,
-- provider = " [LSP]",
local FileTypeElement = {
provider = function()
return string.format(" %s ", vim.bo.filetype)
end,
hl = { fg = colors.dim },
}

-- Or complicate things a bit and get the servers names
local LSPElement = {
condition = conditions.lsp_attached,
provider = function()
local servers = vim.lsp.buf_get_clients(0)
if #servers == 0 then
return string.format(" %s ", vim.bo.filetype)
elseif #servers == 1 then
return " LSP "
else
return (" LSP(%s) "):format(#servers)
end
return (" %s "):format(#servers)
end,

on_click = {
callback = function()
vim.cmd("LspInfo")
end,
name = "lspconfig",
},
hl = { fg = colors.dim },
}

Expand Down Expand Up @@ -426,7 +467,9 @@ statusline.configs["heirline.nvim"] = function()
{ FileBlock },
{ FileEncoding },
{ provider = " %= " },
{ LSPActive },
{ MasonStatusElement },
{ FileTypeElement },
{ LSPElement },
{ GitBlock },
{ Ruler },
{ Notch },
Expand Down
104 changes: 84 additions & 20 deletions lua/doom/modules/langs/bash/init.lua
Original file line number Diff line number Diff line change
@@ -1,32 +1,96 @@
local bash = {}

bash.settings = {
--- disables auto installing the treesitter
--- @type boolean
disable_treesitter = false,
--- treesitter grammars to install
--- @type string|string[]
treesitter_grammars = "bash",

--- disables default lsp config
--- @type boolean
disable_lsp = false,
--- name of the language server
--- @type string
language_server_name = "bashls",

--- disables null-ls formatting sources
--- @type boolean
disable_formatting = false,
--- mason.nvim package to auto install the formatter from
--- @type string
formatting_package = "shfmt",
--- string to access the null_ls diagnositcs provider
--- @type string
formatting_provider = "builtins.formatting.shfmt",
--- function to configure null-ls formatter
--- @type function|nil
formatting_config = nil,

--- disables null-ls diagnostic sources
--- @type boolean
disable_diagnostics = false,
--- mason.nvim package to auto install the diagnostics provider from
--- @type string
diagnostics_package = "shellcheck",
--- string to access the null_ls diagnositcs provider
--- @type string
diagnostics_provider = "builtins.diagnostics.shellcheck",
--- function to configure null-ls diagnostics
--- @type function|nil
diagnostics_config = nil,

--- disables null-ls diagnostic sources
--- @type boolean
disable_code_actions = false,
--- mason.nvim package to auto install the code_actions provider from
--- @type string
code_actions_package = "shellcheck",
--- string to access the null_ls diagnositcs provider
--- @type string
code_actions_provider = "builtins.code_actions.shellcheck",
--- function to configure null-ls code_actions
--- @type function|nil
code_actions_config = nil,
}

local langs_utils = require("doom.modules.langs.utils")
bash.autocmds = {
{
"BufWinEnter",
"*.sh",
function()
local langs_utils = require("doom.modules.langs.utils")
langs_utils.use_lsp(doom.langs.bash.settings.language_server_name)

vim.defer_fn(function()
require("nvim-treesitter.install").ensure_installed("bash")
end, 0)

-- Setup null-ls
if doom.features.linter then
local null_ls = require("null-ls")

langs_utils.use_null_ls_source({
null_ls.builtins.formatting.shfmt,
null_ls.builtins.code_actions.shellcheck,
null_ls.builtins.diagnostics.shellcheck,
})
"FileType",
"bash,sh",
langs_utils.wrap_language_setup("bash", function()
if not bash.settings.disable_lsp then
langs_utils.use_lsp_mason(bash.settings.language_server_name)
end

if not bash.settings.disable_treesitter then
langs_utils.use_tree_sitter(bash.settings.treesitter_grammars)
end

if not bash.settings.disable_formatting then
langs_utils.use_null_ls(
bash.settings.formatting_package,
bash.settings.formatting_provider,
bash.settings.formatting_config
)
end
if not bash.settings.disable_diagnostics then
langs_utils.use_null_ls(
bash.settings.diagnostics_package,
bash.settings.diagnostics_provider,
bash.settings.diagnostics_config
)
end
if not bash.settings.disable_code_actions then
langs_utils.use_null_ls(
bash.settings.code_actions_package,
bash.settings.code_actions_provider,
bash.settings.code_actions_config
)
end
end,
end),
once = true,
},
}
Expand Down
Loading