Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Huge UI Changes #4

Merged
merged 1 commit into from
May 30, 2024
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
5 changes: 0 additions & 5 deletions config/base/keymaps.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
key = "]d";
action = "<cmd>lua vim.diagnostic.goto_next()<cr>";
}
{
mode = "n";
key = "<Space>e";
action = "<cmd>lua vim.diagnostic.open_float()<cr>";
}
{
mode = "n";
key = "<Space>q";
Expand Down
111 changes: 32 additions & 79 deletions config/plugins/completion/cmp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,96 +8,49 @@

cmp = {
enable = true;

autoEnableSources = true;

settings = {
experimental = {
ghost_text = false;
native_menu = false;
};
snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end";
mapping = {
"<C-u>" = "cmp.mapping.scroll_docs(-4)"; # Up
"<C-d>" = "cmp.mapping.scroll_docs(4)"; # Down
"<C-Space>" = "cmp.mapping.complete()";
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
"<C-e>" = "cmp.mapping.close()";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<CR>" = "cmp.mapping.confirm({ select = true, behavior = cmp.ConfirmBehavior.Replace })";

"<Tab>" = ''
cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
print("Luasnip can expand or jump!")
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" })
'';

"<S-Tab>" = ''
cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" })
'';
"<S-Tab>" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})";
"<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
};

sources = [
{
name = "nvim_lsp";
priority = 1;
}
{
name = "nvim_lua";
priority = 2;
}
{
name = "luasnip";
priority = 3;
}
{
name = "buffer";
priority = 4;
}
{ name = "path"; }
{ name = "nvim_lua"; }
{ name = "nvim_lsp"; }
{ name = "luasnip"; }
{ name = "buffer"; }
{ name = "emoji"; }
{ name = "cmdli"; }
];
window = {
completion = { };
documentation = { };

experimental = {
ghost_text = {
hl_group = "CmpGhostText";
};
};
snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end";
};
};
};

extraConfigLua = ''
luasnip = require("luasnip")

kind_icons = {
Text = "󰊄 ",
Method = " ",
Function = "󰡱 ",
Constructor = " ",
Field = " ",
Variable = "󱀍 ",
Class = " ",
Interface = " ",
Module = "󰕳 ",
Property = " ",
Unit = " ",
Value = " ",
Enum = " ",
Keyword = " ",
Snippet = " ",
Color = " ",
File = " ",
Reference = " ",
Folder = " ",
EnumMember = " ",
Constant = " ",
Struct = " ",
Event = " ",
Operator = " ",
TypeParameter = " ",
}

local cmp = require'cmp'
cmp.setup({
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
})
'';
}
5 changes: 5 additions & 0 deletions config/plugins/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
# Misc
./misc/neocord.nix
./misc/wakatime.nix
./misc/comment.nix
./misc/neotree.nix
./misc/mini.nix

# UI
./ui/lualine.nix
Expand All @@ -34,5 +37,7 @@
./ui/bufferline.nix
./ui/nvim-colorizer.nix
./ui/todo.nix
./ui/nvim-notify.nix
./ui/noice.nix
];
}
46 changes: 46 additions & 0 deletions config/plugins/git/gitsigns.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,51 @@
{
plugins.gitsigns = {
enable = true;
settings = {
signs = {
add = {
text = "▎";
};
change = {
text = "▎";
};
delete = {
text = "";
};
topdelete = {
text = "";
};
changedelete = {
text = "▎";
};
untracked = {
text = "▎";
};
};

on_attach = ''
function(buffer)
local gs = package.loaded.gitsigns

local function map(mode, l, r, desc)
vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc })
end

-- stylua: ignore start
map("n", "]h", gs.next_hunk, "Next Hunk")
map("n", "[h", gs.prev_hunk, "Prev Hunk")
map({ "n", "v" }, "<leader>ghs", ":Gitsigns stage_hunk<CR>", "Stage Hunk")
map({ "n", "v" }, "<leader>ghr", ":Gitsigns reset_hunk<CR>", "Reset Hunk")
map("n", "<leader>ghS", gs.stage_buffer, "Stage Buffer")
map("n", "<leader>ghu", gs.undo_stage_hunk, "Undo Stage Hunk")
map("n", "<leader>ghR", gs.reset_buffer, "Reset Buffer")
map("n", "<leader>ghp", gs.preview_hunk, "Preview Hunk")
map("n", "<leader>ghb", function() gs.blame_line({ full = true }) end, "Blame Line")
map("n", "<leader>ghd", gs.diffthis, "Diff This")
map("n", "<leader>ghD", function() gs.diffthis("~") end, "Diff This ~")
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", "GitSigns Select Hunk")
end
'';
};
};
}
10 changes: 9 additions & 1 deletion config/plugins/lsp/lsp.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
{
plugins = {
lsp-lines.enable = true;
luasnip.enable = true;

luasnip = {
enable = true;
extraConfig = {
history = true;
delete_check_events = "TextChanged";
fromVscode = [ { lazyLoad = true; } ];
};
};

lspkind = {
enable = true;
Expand Down
1 change: 1 addition & 0 deletions config/plugins/misc/comment.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ plugins.comment.enable = true; }
84 changes: 84 additions & 0 deletions config/plugins/misc/mini.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
plugins.mini = {
enable = true;
modules = {
pairs = { };
bufremove = { };
comment = {
custom_commentstring = ''
function()
return require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring
end
'';
};
surround = {
mappings = {
add = "gsa"; # -- Add surrounding in Normal and Visual modes
delete = "gsd"; # -- Delete surrounding
find = "gsf"; # -- Find surrounding (to the right)
find_left = "gsF"; # -- Find surrounding (to the left)
highlight = "gsh"; # -- Highlight surrounding
replace = "gsr"; # -- Replace surrounding
update_n_lines = "gsn"; # -- Update `n_lines`
};
};
ai = {
n_lines = 500;
custom_textobjects = {
o = ''
ai.gen_spec.treesitter({
a = { "@block.outer", "@conditional.outer", "@loop.outer" },
i = { "@block.inner", "@conditional.inner", "@loop.inner" },
}, {})'';
f = ''ai.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }, {})'';
c = ''ai.gen_spec.treesitter({ a = "@class.outer", i = "@class.inner" }, {})'';
t = ''{ "<([%p%w]-)%f[^<%w][^<>]->.-</%1>", "^<.->().*()</[^/]->$" }'';
};
};
};
};
keymaps = [
{
action = ''
function()
vim.g.minipairs_disable = not vim.g.minipairs_disable
end
'';
key = "<leader>up";
options.desc = "Toggle auto pairs";
}
{
action = ''
function()
local bd = require("mini.bufremove").delete
if vim.bo.modified then
local choice = vim.fn.confirm(("Save changes to %q?"):format(vim.fn.bufname()), "&Yes\n&No\n&Cancel")
if choice == 1 then -- Yes
vim.cmd.write()
bd(0)
elseif choice == 2 then -- No
bd(0, true)
end
else
bd(0)
end
end
'';
key = "<leader>bd";
options = {
desc = "Delete Buffer";
};
}
{
action = ''
function()
require("mini.bufremove").delete(0, true)
end
'';
key = "<leader>bD";
options = {
desc = "Delete Buffer (Force)";
};
}
];
}
51 changes: 51 additions & 0 deletions config/plugins/misc/neotree.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
plugins.neo-tree = {
enable = true;
sources = [
"filesystem"
"buffers"
"git_status"
"document_symbols"
];
filesystem = {
bindToCwd = false;
followCurrentFile = {
enabled = true;
};
useLibuvFileWatcher = true;
};
window.mappings = {
"<space>" = "none";
"Y" = ''
function(state)
local node = state.tree:get_node()
local path = node:get_id()
vim.fn.setreg("+", path, "c")
end
'';
};
defaultComponentConfigs = {
indent = {
withExpanders = true;
expanderCollapsed = "";
expanderExpanded = "";
expanderHighlight = "NeoTreeExpander";
};
gitStatus.symbols = {
unstaged = "󰄱";
staged = "󰱒";
};
};
};

keymaps = [
{
action = "<cmd>Neotree<CR>";
key = "<leader>e";
options = {
desc = "Explorer Neotree";
silent = true;
};
}
];
}
9 changes: 9 additions & 0 deletions config/plugins/ui/bufferline.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
plugins.bufferline = {
enable = true;
diagnostics = "nvim_lsp";
offsets = [
{
filetype = "CHADTree";
highlight = "Directory";
text = "File Explorer";
text_align = "center";
}
];
};
}
Loading