From c702814d039d4dacd373859d3a314364c9a205c4 Mon Sep 17 00:00:00 2001 From: Erik Reinert <4638629+erikreinert@users.noreply.github.com> Date: Tue, 19 Mar 2024 11:32:36 -0700 Subject: [PATCH] Update plugins version (#9) * feat(flake): added copilot chat derivation * feat(languages): added postgres lsp support * feat(plugins): update copilot chat version * feat(lib): update binaries to include secrets * refactor: update key mappings and package references * feat: Replace nerdcommenter with comment-nvim This commit replaces the nerdcommenter plugin with comment-nvim for better commenting functionality. It also adds a new keymap for committing staged changes using CopilotChat. Minor adjustments are made to the setup of notify and noice plugins. --- flake.lock | 24 ++++++++++++++++++++--- flake.nix | 13 +++++++++++-- justfile | 3 +++ lib/default.nix | 33 ++++++++++++++++++++------------ lua/TheAltF4Stream/chatgpt.lua | 20 +++++++++---------- lua/TheAltF4Stream/copilot.lua | 25 +++++++++++++++++------- lua/TheAltF4Stream/floaterm.lua | 16 +++++++--------- lua/TheAltF4Stream/languages.lua | 6 ++++++ lua/TheAltF4Stream/telescope.lua | 28 +++++++++++++-------------- lua/TheAltF4Stream/theme.lua | 30 ++++++++++++++++++++++++++--- lua/TheAltF4Stream/vim.lua | 11 +++++------ 11 files changed, 141 insertions(+), 68 deletions(-) diff --git a/flake.lock b/flake.lock index f3b655f..95c0d90 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,22 @@ { "nodes": { + "copilotchat": { + "flake": false, + "locked": { + "lastModified": 1710849460, + "narHash": "sha256-YRfe53MfqmRkgM2YgdYjps1FvhcDeqiSwuPe7YMIM7k=", + "owner": "CopilotC-Nvim", + "repo": "CopilotChat.nvim", + "rev": "4811cdd91b35345358da89f0eedd1f2b92c8bf04", + "type": "github" + }, + "original": { + "owner": "CopilotC-Nvim", + "ref": "canary", + "repo": "CopilotChat.nvim", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -19,11 +36,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1709703039, - "narHash": "sha256-6hqgQ8OK6gsMu1VtcGKBxKQInRLHtzulDo9Z5jxHEFY=", + "lastModified": 1710806803, + "narHash": "sha256-qrxvLS888pNJFwJdK+hf1wpRCSQcqA6W5+Ox202NDa0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9df3e30ce24fd28c7b3e2de0d986769db5d6225d", + "rev": "b06025f1533a1e07b6db3e75151caa155d1c7eb3", "type": "github" }, "original": { @@ -53,6 +70,7 @@ }, "root": { "inputs": { + "copilotchat": "copilotchat", "flake-parts": "flake-parts", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index 7b2d81e..3e5a554 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,8 @@ { description = "Neovim configuration for TheAltF4Stream as a plugin"; + inputs.copilotchat.flake = false; + inputs.copilotchat.url = "github:CopilotC-Nvim/CopilotChat.nvim?ref=canary"; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; outputs = inputs @ { @@ -24,15 +26,22 @@ system, ... }: let - inherit (pkgs) just mkShell; + inherit (pkgs) alejandra just mkShell; in { + apps = { + nvim = { + program = "${config.packages.neovim}/bin/nvim"; + type = "app"; + }; + }; + devShells = { default = mkShell { buildInputs = [just]; }; }; - formatter = pkgs.alejandra; + formatter = alejandra; packages = { default = self.lib.mkVimPlugin {inherit system;}; diff --git a/justfile b/justfile index d2441ba..01d7b00 100644 --- a/justfile +++ b/justfile @@ -15,3 +15,6 @@ cache-shell cache_name="altf4llc-os": check: nix flake check + +update: + nix flake update diff --git a/lib/default.nix b/lib/default.nix index 2d17efd..71301c2 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,6 +1,16 @@ {inputs}: let inherit (inputs.nixpkgs) legacyPackages; in rec { + mkCopilotChat = {system}: let + inherit (pkgs) vimUtils; + inherit (vimUtils) buildVimPlugin; + pkgs = legacyPackages.${system}; + in + buildVimPlugin { + name = "CopilotChat"; + src = inputs.copilotchat; + }; + mkVimPlugin = {system}: let inherit (pkgs) vimUtils; inherit (vimUtils) buildVimPlugin; @@ -23,8 +33,9 @@ in rec { mkNeovimPlugins = {system}: let inherit (pkgs) vimPlugins; + CopilotChat-nvim = mkCopilotChat {inherit system;}; pkgs = legacyPackages.${system}; - thealtf4stream-nvim = mkVimPlugin {inherit system;}; + TheAltF4Stream-nvim = mkVimPlugin {inherit system;}; in [ # languages vimPlugins.nvim-lspconfig @@ -43,11 +54,13 @@ in rec { vimPlugins.vim-floaterm # extras + CopilotChat-nvim vimPlugins.ChatGPT-nvim + vimPlugins.comment-nvim vimPlugins.copilot-lua vimPlugins.gitsigns-nvim vimPlugins.lualine-nvim - vimPlugins.nerdcommenter + vimPlugins.noice-nvim vimPlugins.nui-nvim vimPlugins.nvim-colorizer-lua vimPlugins.nvim-notify @@ -58,12 +71,11 @@ in rec { vimPlugins.trouble-nvim # configuration - thealtf4stream-nvim + TheAltF4Stream-nvim ]; mkExtraPackages = {system}: let - inherit (pkgs) nodePackages ocamlPackages python311Packages; - + inherit (pkgs) nodePackages ocamlPackages python3Packages; pkgs = import inputs.nixpkgs { inherit system; config.allowUnfree = true; @@ -88,6 +100,7 @@ in rec { pkgs.lua-language-server pkgs.nil pkgs.omnisharp-roslyn + pkgs.postgres-lsp pkgs.rust-analyzer pkgs.terraform-ls @@ -97,14 +110,10 @@ in rec { pkgs.golines pkgs.rustfmt pkgs.terraform - python311Packages.black + python3Packages.black - # support - python311Packages.prompt-toolkit - python311Packages.pynvim - python311Packages.python-dotenv - python311Packages.requests - python311Packages.tiktoken + # secrets + pkgs.doppler ]; mkExtraConfig = '' diff --git a/lua/TheAltF4Stream/chatgpt.lua b/lua/TheAltF4Stream/chatgpt.lua index 7b0207e..055bb01 100644 --- a/lua/TheAltF4Stream/chatgpt.lua +++ b/lua/TheAltF4Stream/chatgpt.lua @@ -5,21 +5,19 @@ local function init() chatgpt.setup({ api_key_cmd = api_key_cmd, - openai_params = { max_tokens = 128000, model = "gpt-4-turbo-preview" }, + openai_params = { model = "gpt-4-turbo-preview" }, openai_edit_params = { model = "gpt-4" } }) - local map = vim.api.nvim_set_keymap + local options = { noremap = true, silent = true } - local options = { noremap = true } - - map('n', 'ga', 'ChatGPTActAs', options) - map('n', 'gg', 'ChatGPT', options) - map('v', 'ge', 'ChatGPTEditWithInstructions', options) - map('v', 'gb', 'ChatGPTRun fix_bugs', options) - map('v', 'go', 'ChatGPTRun optimize_code', options) - map('v', 'gs', 'ChatGPTRun summarize', options) - map('v', 'gt', 'ChatGPTRun add_tests', options) + vim.keymap.set('n', 'ga', 'ChatGPTActAs', options) + vim.keymap.set('n', 'gg', 'ChatGPT', options) + vim.keymap.set('v', 'ge', 'ChatGPTEditWithInstruction', options) + vim.keymap.set('v', 'gb', 'ChatGPTRun fix_bugs', options) + vim.keymap.set('v', 'go', 'ChatGPTRun optimize_code', options) + vim.keymap.set('v', 'gs', 'ChatGPTRun summarize', options) + vim.keymap.set('v', 'gt', 'ChatGPTRun add_tests', options) end return { diff --git a/lua/TheAltF4Stream/copilot.lua b/lua/TheAltF4Stream/copilot.lua index 38c436e..173d0e1 100644 --- a/lua/TheAltF4Stream/copilot.lua +++ b/lua/TheAltF4Stream/copilot.lua @@ -1,14 +1,25 @@ -local copilot_chat = require("CopilotChat") +local copilotchat = require("CopilotChat") +local copilotchat_select = require("CopilotChat.select") -local function init() - copilot_chat.setup() +local function CopilotChatWithInput() + local input = vim.fn.input("Prompt: ") + if input ~= "" then + copilotchat.ask(input, { selection = copilotchat_select.visual }) + end +end - local map = vim.api.nvim_set_keymap +local function init() + copilotchat.setup { debug = false } - local options = { noremap = true } + local options = { noremap = true, silent = true } - map('n', 'co', ':lua require("CopilotChat.code_actions").show_help_actions()', options) - map('n', 'cp', ':lua require("CopilotChat.code_actions").show_prompt_actions(true)', options) + vim.keymap.set('n', 'cm', "CopilotChatCommitStaged", options) + vim.keymap.set('v', 'ce', "CopilotChatExplain", options) + vim.keymap.set('n', 'cf', "CopilotChatFixDiagnostic", options) + vim.keymap.set('v', 'cd', "CopilotChatDocs", options) + vim.keymap.set('v', 'co', "CopilotChatOptimize", options) + vim.keymap.set('v', 'cp', CopilotChatWithInput, options) + vim.keymap.set('v', 'ct', "CopilotChatTests", options) end return { diff --git a/lua/TheAltF4Stream/floaterm.lua b/lua/TheAltF4Stream/floaterm.lua index 7dfa6e1..0db5ce7 100644 --- a/lua/TheAltF4Stream/floaterm.lua +++ b/lua/TheAltF4Stream/floaterm.lua @@ -1,14 +1,12 @@ local function init() - local map = vim.api.nvim_set_keymap + local options = { noremap = true, silent = true } - local options = { noremap = true } - - map('n', 'bb', 'FloatermNew --autoclose=2 --height=0.9 --width=0.9 btm', options) - map('n', 'k9', 'FloatermNew --autoclose=2 --height=0.9 --width=0.9 k9s', options) - map('n', 'ld', 'FloatermNew --autoclose=2 --height=0.9 --width=0.9 lazydocker', options) - map('n', 'lg', 'FloatermNew --autoclose=2 --height=0.9 --width=0.9 lazygit', options) - map('n', 'nn', 'FloatermNew --autoclose=2 --height=0.75 --width=0.75 nnn -Hde', options) - map('n', 'tt', 'FloatermNew --autoclose=2 --height=0.9 --width=0.9 zsh', options) + vim.keymap.set('n', 'bb', 'FloatermNew --autoclose=2 --height=0.9 --width=0.9 btm', options) + vim.keymap.set('n', 'k9', 'FloatermNew --autoclose=2 --height=0.9 --width=0.9 k9s', options) + vim.keymap.set('n', 'ld', 'FloatermNew --autoclose=2 --height=0.9 --width=0.9 lazydocker', options) + vim.keymap.set('n', 'lg', 'FloatermNew --autoclose=2 --height=0.9 --width=0.9 lazygit', options) + vim.keymap.set('n', 'nn', 'FloatermNew --autoclose=2 --height=0.75 --width=0.75 nnn -Hde', options) + vim.keymap.set('n', 'tt', 'FloatermNew --autoclose=2 --height=0.9 --width=0.9 zsh', options) end return { diff --git a/lua/TheAltF4Stream/languages.lua b/lua/TheAltF4Stream/languages.lua index a22997a..7ff4214 100644 --- a/lua/TheAltF4Stream/languages.lua +++ b/lua/TheAltF4Stream/languages.lua @@ -149,6 +149,7 @@ local function init() ["textDocument/definition"] = omnisharp_extended.handler, }, }, + postgres_lsp = {}, pyright = { settings = { python = { @@ -192,9 +193,14 @@ local function init() vim.keymap.set('n', 'q', vim.diagnostic.setloclist) treesitter.setup { + auto_install = false, + ensure_installed = {}, highlight = { enable = true }, + ignore_install = {}, indent = { enable = true }, + modules = {}, rainbow = { enable = true }, + sync_install = false, } treesitter_context.setup() diff --git a/lua/TheAltF4Stream/telescope.lua b/lua/TheAltF4Stream/telescope.lua index db1c4db..80e3bdc 100644 --- a/lua/TheAltF4Stream/telescope.lua +++ b/lua/TheAltF4Stream/telescope.lua @@ -24,27 +24,25 @@ local function init() telescope.load_extension('notify') - local map = vim.api.nvim_set_keymap - - local options = { noremap = true } + local options = { noremap = true, silent = true } -- Builtin - map('n', 'fg', 'lua require("telescope.builtin").git_files{}', options) - map('n', 'ff', 'lua require("telescope.builtin").find_files{ hidden = true }', options) - map('n', 'fl', 'lua require("telescope.builtin").live_grep()', options) - map('n', 'fb', 'lua require("telescope.builtin").buffers()', options) - map('n', 'fh', 'lua require("telescope.builtin").help_tags()', options) - map('n', 'fd', 'lua require("telescope.builtin").diagnostics()', options) - map('n', 'fr', 'lua require("telescope.builtin").registers()', options) + vim.keymap.set('n', 'fg', 'lua require("telescope.builtin").git_files{}', options) + vim.keymap.set('n', 'ff', 'lua require("telescope.builtin").find_files{ hidden = true }', options) + vim.keymap.set('n', 'fl', 'lua require("telescope.builtin").live_grep()', options) + vim.keymap.set('n', 'fb', 'lua require("telescope.builtin").buffers()', options) + vim.keymap.set('n', 'fh', 'lua require("telescope.builtin").help_tags()', options) + vim.keymap.set('n', 'fd', 'lua require("telescope.builtin").diagnostics()', options) + vim.keymap.set('n', 'fr', 'lua require("telescope.builtin").registers()', options) -- Language Servers - map('n', 'lsd', 'lua require("telescope.builtin").lsp_definitions{}', options) - map('n', 'lsi', 'lua require("telescope.builtin").lsp_implementations{}', options) - map('n', 'lsl', 'lua require("telescope.builtin").lsp_code_actions{}', options) - map('n', 'lst', 'lua require("telescope.builtin").lsp_type_definitions{}', options) + vim.keymap.set('n', 'lsd', 'lua require("telescope.builtin").lsp_definitions{}', options) + vim.keymap.set('n', 'lsi', 'lua require("telescope.builtin").lsp_implementations{}', options) + vim.keymap.set('n', 'lsl', 'lua require("telescope.builtin").lsp_code_actions{}', options) + vim.keymap.set('n', 'lst', 'lua require("telescope.builtin").lsp_type_definitions{}', options) -- Extensions - map('n', 'fn', 'lua require("telescope").extensions.notify.notify()', options) + vim.keymap.set('n', 'fn', 'lua require("telescope").extensions.notify.notify()', options) end return { diff --git a/lua/TheAltF4Stream/theme.lua b/lua/TheAltF4Stream/theme.lua index 1150861..55218b3 100644 --- a/lua/TheAltF4Stream/theme.lua +++ b/lua/TheAltF4Stream/theme.lua @@ -1,19 +1,43 @@ local colorizer = require 'colorizer' local gitsigns = require 'gitsigns' local lualine = require 'lualine' +local noice = require 'noice' +local notify = require 'notify' local oxocarbon = require('oxocarbon').oxocarbon +local comment = require 'Comment' local function init() colorizer.setup {} + comment.setup {} + gitsigns.setup {} lualine.setup { options = { - component_separators = { left = '', right = '' }, extensions = { "fzf", "quickfix" }, - icons_enabled = false, - section_separators = { left = '', right = '' }, + }, + } + + notify.setup { + background_colour = "#000000", + render = "wrapped-compact", + timeout = 2500, + } + + noice.setup { + lsp = { + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + }, + }, + presets = { + bottom_search = true, + command_palette = true, + inc_rename = false, + long_message_to_split = true, + lsp_doc_border = false, }, } diff --git a/lua/TheAltF4Stream/vim.lua b/lua/TheAltF4Stream/vim.lua index 96ff8d9..3a55070 100644 --- a/lua/TheAltF4Stream/vim.lua +++ b/lua/TheAltF4Stream/vim.lua @@ -42,13 +42,12 @@ local function set_vim_opt() end local function set_vim_keymaps() - local map = vim.api.nvim_set_keymap - local options = { noremap = false } + local options = { noremap = false, silent = true } - map('n', 'h', 'wincmd h', options) - map('n', 'j', 'wincmd j', options) - map('n', 'k', 'wincmd k', options) - map('n', 'l', 'wincmd l', options) + vim.keymap.set('n', 'h', 'wincmd h', options) + vim.keymap.set('n', 'j', 'wincmd j', options) + vim.keymap.set('n', 'k', 'wincmd k', options) + vim.keymap.set('n', 'l', 'wincmd l', options) end local function init()