Skip to content

Commit

Permalink
refactor: stylua fixes and start to build from core
Browse files Browse the repository at this point in the history
  • Loading branch information
polarmutex authored and Brian Ryall committed Dec 28, 2023
1 parent 7f6377f commit 95ac3aa
Show file tree
Hide file tree
Showing 18 changed files with 934 additions and 2,028 deletions.
2 changes: 2 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
self = false

ignore = {
}
read_globals = {
Expand Down
6 changes: 6 additions & 0 deletions .stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 4
quote_style = "AutoPreferSingle"
call_parentheses = "NoSingleTable"
collapse_simple_statement = "Never"
42 changes: 22 additions & 20 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,19 @@
name = "haskell-tools.nvim-shell";
inherit (pre-commit-check) shellHook;
buildInputs =
(with pkgs; [
with pkgs; [
neorocks
haskellPackages.neolua-bin
])
++ (with inputs.pre-commit-hooks.packages.${system}; [
alejandra
lua-language-server
stylua
luacheck
markdownlint-cli
]);
]
#++ (with inputs.pre-commit-hooks.packages.${system}; [
# alejandra
# lua-language-server
# stylua
# luacheck
# markdownlint-cli
#])
;
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [];
};
};
Expand All @@ -100,18 +102,18 @@

checks = {
inherit pre-commit-check;
# type-check-stable = pkgs.callPackage ./nix/type-check.nix {
# stable = true;
# inherit (config.packages) neodev-plugin telescope-plugin;
# inherit (inputs) pre-commit-hooks;
# inherit self;
# };
# type-check-nightly = pkgs.callPackage ./nix/type-check.nix {
# stable = false;
# inherit (config.packages) neodev-plugin telescope-plugin;
# inherit (inputs) pre-commit-hooks;
# inherit self;
# };
type-check-stable = pkgs.callPackage ./nix/type-check.nix {
stable = true;
inherit (config.packages) neodev-plugin telescope-plugin;
inherit (inputs) pre-commit-hooks;
inherit self;
};
type-check-nightly = pkgs.callPackage ./nix/type-check.nix {
stable = false;
inherit (config.packages) neodev-plugin telescope-plugin;
inherit (inputs) pre-commit-hooks;
inherit self;
};
neorocks-test-stable = pkgs.callPackage ./nix/neorocks-test.nix {
name = "git-worktree-stable";
inherit self;
Expand Down
33 changes: 33 additions & 0 deletions lua/git-worktree/config.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
local M = {}

---@class GitWorktreeConfig

---@class GitWorktreePartialConfig
---@field change_directory_command? string
---@field update_on_change? boolean
---@field update_on_change_command? string
---@field clearjumps_on_change? boolean
---@field confirm_telescope_deletions? boolean
---@field autopush? boolean

---@return GitWorktreeConfig
function M.get_default_config()
return {
change_directory_command = 'cd',
update_on_change = true,
update_on_change_command = 'e .',
clearjumps_on_change = true,
confirm_telescope_deletions = true,
autopush = false,
}
end

---@param partial_config GitWorktreePartialConfig
---@param latest_config GitWorktreeConfig?
---@return GitWorktreeConfig
function M.merge_config(partial_config, latest_config)
local config = latest_config or M.get_default_config()

config = vim.tbl_extend('force', config, partial_config)

return config
end

return M
41 changes: 22 additions & 19 deletions lua/git-worktree/enum.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
local Enum = function(tbl)
return setmetatable(tbl, {
__index = function(_, key)
error(string.format("%s does not exist for this enum.", key))
end,

__newindex = function(_, _, _)
error("Enums are immutable. You are not able to set new values")
end,
})
end

return {
Operations = Enum({
Create = "create",
Switch = "switch",
Delete = "delete",
}),
}
-- --- @class GitWorktreeOperation
--
-- --- @return GitWorktreeOperation: A enum reperesenting worktree operation being performed
-- local Enum = function(tbl)
-- return setmetatable(tbl, {
-- __index = function(_, key)
-- error(string.format("%s does not exist for this enum.", key))
-- end,
--
-- __newindex = function(_, _, _)
-- error("Enums are immutable. You are not able to set new values")
-- end,
-- })
-- end
--
-- return {
-- Operation = Enum({
-- Create = "create",
-- Switch = "switch",
-- Delete = "delete",
-- }),
-- }
Loading

0 comments on commit 95ac3aa

Please sign in to comment.