-
-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3fb1c4
commit 309e564
Showing
3 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,7 @@ | |
./lsp/lsp-lines.nix | ||
./lsp/nvim-lightbulb.nix | ||
./lsp/trouble.nix | ||
./lsp/wtf.nix | ||
|
||
./none-ls | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
{ | ||
lib, | ||
helpers, | ||
config, | ||
pkgs, | ||
... | ||
}: | ||
with lib; let | ||
cfg = config.plugins.wtf; | ||
|
||
defaultKeymaps = { | ||
ai = { | ||
key = "gw"; | ||
mode = ["n" "x"]; | ||
action = "require('wtf').ai"; | ||
lua = true; | ||
}; | ||
|
||
search = { | ||
key = "gW"; | ||
mode = "n"; | ||
action = "require('wtf').search"; | ||
lua = true; | ||
}; | ||
}; | ||
in { | ||
options = { | ||
plugins.wtf = | ||
helpers.extraOptionsOptions | ||
// { | ||
enable = mkEnableOption "wtf.nvim"; | ||
|
||
package = helpers.mkPackageOption "wtf.nvim" pkgs.vimPlugins.wtf-nvim; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
GaetanLepage
Author
Member
|
||
|
||
keymaps = | ||
mapAttrs | ||
( | ||
action: defaults: | ||
helpers.mkNullOrOption | ||
( | ||
with types; | ||
either | ||
str | ||
(helpers.keymaps.mkMapOptionSubmodule defaults) | ||
) | ||
"Keymap for the ${action} action." | ||
) | ||
defaultKeymaps; | ||
|
||
popupType = helpers.defaultNullOpts.mkEnum ["popup" "horizontal" "vertical"] "popup" '' | ||
Default AI popup type. | ||
''; | ||
|
||
openaiApiKey = helpers.mkNullOrOption (with types; either str helpers.rawType) '' | ||
An alternative way to set your API key. | ||
''; | ||
|
||
openaiModelId = helpers.defaultNullOpts.mkStr "gpt-3.5-turbo" "ChatGPT Model."; | ||
|
||
context = helpers.defaultNullOpts.mkBool true "Send code as well as diagnostics."; | ||
|
||
language = helpers.defaultNullOpts.mkStr "english" '' | ||
Set your preferred language for the response. | ||
''; | ||
|
||
additionalInstructions = helpers.mkNullOrOption types.str "Any additional instructions."; | ||
|
||
searchEngine = | ||
helpers.defaultNullOpts.mkEnum | ||
["google" "duck_duck_go" "stack_overflow" "github"] | ||
"google" | ||
"Default search engine."; | ||
|
||
hooks = { | ||
requestStarted = helpers.mkNullOrOption types.str "Callback for request start."; | ||
|
||
requestFinished = helpers.mkNullOrOption types.str "Callback for request finished."; | ||
}; | ||
|
||
winhighlight = helpers.defaultNullOpts.mkStr "Normal:Normal,FloatBorder:FloatBorder" '' | ||
Add custom colours. | ||
''; | ||
}; | ||
}; | ||
|
||
config = let | ||
setupOptions = with cfg; | ||
{ | ||
popup_type = popupType; | ||
openai_api_key = openaiApiKey; | ||
openai_model_id = openaiModelId; | ||
inherit | ||
context | ||
language | ||
; | ||
additional_instructions = additionalInstructions; | ||
search_engine = searchEngine; | ||
hooks = { | ||
request_started = helpers.mkRaw hooks.requestStarted; | ||
request_finished = helpers.mkRaw hooks.requestFinished; | ||
}; | ||
inherit winhighlight; | ||
} | ||
// cfg.extraOptions; | ||
in | ||
mkIf cfg.enable { | ||
extraPlugins = [cfg.package]; | ||
|
||
keymaps = filter (keymap: keymap != null) ( | ||
mapAttrsToList | ||
( | ||
action: value: | ||
if isString value | ||
then defaultKeymaps.${action} // {key = value;} | ||
else value | ||
) | ||
cfg.keymaps | ||
); | ||
|
||
extraConfigLua = '' | ||
require("wtf").setup(${helpers.toLuaObject setupOptions}) | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
empty = { | ||
plugins.wtf.enable = true; | ||
}; | ||
|
||
example = { | ||
plugins.wtf = { | ||
enable = true; | ||
|
||
keymaps = { | ||
ai = "gw"; | ||
search = { | ||
mode = ["n" "x"]; | ||
options.desc = "Search diagnostic with Google"; | ||
}; | ||
}; | ||
popupType = "popup"; | ||
openaiApiKey = null; | ||
openaiModelId = "gpt-3.5-turbo"; | ||
context = true; | ||
language = "english"; | ||
additionalInstructions = "Hello world !"; | ||
searchEngine = "google"; | ||
hooks = { | ||
requestStarted = '' | ||
function() | ||
vim.cmd("hi StatusLine ctermbg=NONE ctermfg=yellow") | ||
end | ||
''; | ||
requestFinished = '' | ||
vim.schedule_wrap(function() | ||
vim.cmd("hi StatusLine ctermbg=NONE ctermfg=NONE") | ||
end) | ||
''; | ||
}; | ||
winhighlight = "Normal:Normal,FloatBorder:FloatBorder"; | ||
}; | ||
}; | ||
} |
error: attribute 'wtf-nvim' missing
main is currently broken.