Compare commits

...

3 Commits

Author SHA1 Message Date
Moritz Böhme d6b95fdef6
feat(nvim): add lsp inlay hints 2023-08-11 19:00:43 +02:00
Moritz Böhme 1566dc84f4
refactor(nvim): condense functions 2023-08-11 19:00:11 +02:00
Moritz Böhme 0c591c0435
feat(nvim): add hmts.nvim 2023-08-11 18:59:52 +02:00
7 changed files with 64 additions and 38 deletions

View File

@ -319,6 +319,22 @@
"type": "github"
}
},
"hmts-nvim": {
"flake": false,
"locked": {
"lastModified": 1691525513,
"narHash": "sha256-il5m+GlNt0FzZjefl1q8ZxWHg0+gQps0vigt+eoIy8A=",
"owner": "calops",
"repo": "hmts.nvim",
"rev": "594dd17c870afb7f6517723c8963f6eb144e3c0d",
"type": "github"
},
"original": {
"owner": "calops",
"repo": "hmts.nvim",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -785,6 +801,7 @@
"arkenfox-userjs": "arkenfox-userjs",
"asus-touchpad-numpad-driver": "asus-touchpad-numpad-driver",
"flake-utils": "flake-utils",
"hmts-nvim": "hmts-nvim",
"home-manager": "home-manager_2",
"hypr-contrib": "hypr-contrib",
"hyprland": "hyprland",

View File

@ -44,6 +44,9 @@
telekasten-nvim.flake = false;
telekasten-nvim.url = "github:renerocksai/telekasten.nvim";
hmts-nvim.flake = false;
hmts-nvim.url = "github:calops/hmts.nvim";
# Hyprland
hypr-contrib.url = "github:hyprwm/contrib";
hyprland.url = "github:hyprwm/Hyprland";

View File

@ -50,22 +50,22 @@ in
${exportedVariables}
'';
functions = {
gi = with pkgs; ''
gi = ''
set url https://www.gitignore.io/api
if test (count $argv) -eq 0
set choice ( curl -sL $url/list \
| string split "," \
| ${fzf}/bin/fzf -m \
| ${getExe pkgs.fzf} -m \
| string join "," )
else
set choice (string join "," $argv[1..])
end
if ${gum}/bin/gum confirm "Overwrite current .gitignore?"
${curl}/bin/curl -sL $url/$choice > .gitignore
if ${getExe pkgs.gum} confirm "Overwrite current .gitignore?"
${getExe pkgs.curl} -sL $url/$choice > .gitignore
else
${curl}/bin/curl -sL $url/$choice >> .gitignore
${getExe pkgs.curl} -sL $url/$choice >> .gitignore
end
'';
fish_greeting = "";

View File

@ -12,14 +12,8 @@ let
id = x: x;
listToString = sep: f: list: ''{ ${concatStringsSep sep (map f list)} }'';
listToStringOneLine = listToString ", ";
listToStringMultiLine = listToString ",\n";
keybinding =
{ key
, cmd
, func
, mode
, desc
}:
listToStringMultiLine' = listToString ",\n" id;
keybinding = { key, cmd, func, mode, desc }:
let
cmdString =
if cmd != null
@ -30,39 +24,29 @@ let
then func
else abort "Either cmd or function must be set"
);
descString = optionalString (desc != null) "desc = ${quote desc},";
in
''{ ${quote key}, ${cmdString}, mode = ${quote mode}, ${optionalString (desc != null) "desc = ${quote desc},"} }'';
''{ ${quote key}, ${cmdString}, mode = ${quote mode}, ${descString} }'';
lazySpecFromPlugin =
{ plugin
, dependencies
, init
, conf
, lazy
, event
, enabled
, cmd
, ft
, priority
, keys
}:
listToStringMultiLine id
{ plugin, dependencies, init, conf, lazy, event, enabled, cmd, ft, priority, keys }:
listToStringMultiLine'
([
"dir = ${quote plugin}"
"name = ${quote (getName plugin)}"
]
++ (optional (lazy != null) "lazy = ${boolToString lazy}")
++ (optional (!enabled) "enabled = ${boolToString enabled}")
++ (optional (dependencies != [ ]) "dependencies = ${listToStringMultiLine id (map lazySpecFromPlugin dependencies)}")
++ (optional (dependencies != [ ]) "dependencies = ${listToStringMultiLine' (map lazySpecFromPlugin dependencies)}")
++ (optional (init != null) "init = function(plugin)\n${toString init}\nend")
++ (optional (conf != null) "config = function(plugin, opts)\n${toString conf}\nend")
++ (optional (keys != [ ]) "keys = ${listToStringMultiLine id (map keybinding keys)}")
++ (optional (keys != [ ]) "keys = ${listToStringMultiLine' (map keybinding keys)}")
++ (optional (event != [ ]) "event = ${listToStringOneLine quote event}")
++ (optional (cmd != [ ]) "cmd = ${listToStringOneLine quote cmd}")
++ (optional (ft != [ ]) "ft = ${listToStringOneLine quote ft}")
++ (optional (priority != null) "priority = ${toString priority}")
);
lazySpecs = listToStringMultiLine id (map lazySpecFromPlugin cfg.plugins);
lazy = ''
lazySpecs = listToStringMultiLine' (map lazySpecFromPlugin cfg.plugins);
lazy = /* lua */ ''
require("lazy").setup(${lazySpecs})
'';
in

View File

@ -47,7 +47,7 @@ with builtins;
{ key = "<leader>st"; cmd = "<cmd>TodoTelescope<cr>"; desc = "Todo"; }
{
key = "[q";
func = ''function()
func = /* lua */ ''function()
if require("trouble").is_open() then
require("trouble").previous({ skip_groups = true, jump = true })
else
@ -58,7 +58,7 @@ with builtins;
}
{
key = "]q";
func = ''function()
func = /* lua */ ''function()
if require("trouble").is_open() then
require("trouble").next({ skip_groups = true, jump = true })
else
@ -200,7 +200,7 @@ with builtins;
{
plugin = comment-nvim;
event = [ "BufReadPost" "BufNewFile" ];
conf = ''
conf = /* lua */ ''
require("Comment").setup()
'';
}
@ -243,14 +243,14 @@ with builtins;
{
plugin = nvim-surround;
event = [ "BufReadPost" "BufNewFile" ];
conf = ''
conf = /* lua */ ''
require("nvim-surround").setup({})
'';
}
{
plugin = nvim-treesitter-context;
event = [ "BufReadPost" "BufNewFile" ];
conf = ''
conf = /* lua */ ''
require("treesitter-context").setup({})
'';
}
@ -258,5 +258,9 @@ with builtins;
plugin = dressing-nvim;
event = [ "VeryLazy" ];
}
{
plugin = hmts-nvim;
ft = [ "nix" ];
}
];
}

View File

@ -54,7 +54,7 @@ capabilities.textDocument.foldingRange = {
require("ufo").setup()
local lspconfig = require("lspconfig")
local on_attach_def = function(_, bufnr)
local on_attach_def = function(client, bufnr)
require("which-key").register({
K = { vim.lsp.buf.hover, "Hover" },
["<leader>"] = {
@ -71,7 +71,13 @@ local on_attach_def = function(_, bufnr)
},
},
t = {
l = { lsp_lines.toggle, "Lsp lines" },
l = { lsp_lines.toggle, "LSP lines" },
i = {
function()
vim.lsp.inlay_hint(bufnr, nil)
end,
"LSP inlay hints",
},
},
},
g = {
@ -99,6 +105,12 @@ local on_attach_def = function(_, bufnr)
d = { vim.diagnostic.goto_next, "Next diagnostic" },
},
}, { buffer = bufnr, silent = true })
if client.server_capabilities.inlayHintProvider then
vim.defer_fn(function()
vim.lsp.inlay_hint(bufnr, true)
end, 1000)
end
end
local lspconfig_default_options = {

View File

@ -21,5 +21,11 @@ with lib.my;
version = mkVersionInput inputs.telekasten-nvim;
src = inputs.telekasten-nvim;
};
hmts-nvim = prev.vimUtils.buildVimPluginFrom2Nix {
pname = "hmts-nvim";
version = mkVersionInput inputs.hmts-nvim;
src = inputs.hmts-nvim;
};
};
}