From b3ba49ec4b113367d395641ffc43f57839c7673e Mon Sep 17 00:00:00 2001 From: Joao P Dubas Date: Wed, 11 Dec 2024 11:38:13 +0000 Subject: [PATCH] feat(neovim): upgrade kickstart neovim configuration (#128) Besides upgrading `kickstart` configuration, the following changes were made: * add `avante` to start working with `AI` code generation and reduce code boilerplate creation * configure ide image/container with environment variables: * `NVIM_GIT_USER_EMAIL`: email associated with git commit * `NVIM_GIT_USER_NAME`: name associated with git commit * `NVIM_ANTHROPIC_API_KEY`: `anthropic` api key, used by `avante` * `NVIM_GH_TOKEN`: `github` token, used by `github cli` Reviewed-on: https://gitea.dubas.dev/joao.dubas/ide/pulls/128 Co-authored-by: Joao P Dubas Co-committed-by: Joao P Dubas --- Dockerfile | 2 +- config/nvim/lua/custom/plugins/init.lua | 120 ++++++++++++++++++++++++ docker-compose.yml | 9 +- patch/kickstart.nvim/updates.patch | 19 ++-- 4 files changed, 138 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 942c0c3..49a0b6e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -184,7 +184,7 @@ COPY ./patch/kickstart.nvim/updates.patch /tmp COPY ./config/nvim/lua/custom/plugins/init.lua /tmp RUN git clone https://github.com/nvim-lua/kickstart.nvim.git "${XDG_CONFIG_HOME}"/nvim \ && cd ${XDG_CONFIG_HOME}/nvim \ - && git reset --hard 4120893b8a1f31a0957f2f891f7fbef73ddfb9b1 \ + && git reset --hard 8d1ef972bc32faa86fee21a57f9033b41f612ebb \ && git apply /tmp/updates.patch \ && cp /tmp/init.lua ${XDG_CONFIG_HOME}/nvim/lua/custom/plugins \ && nvim --headless "+Lazy! sync" +qa diff --git a/config/nvim/lua/custom/plugins/init.lua b/config/nvim/lua/custom/plugins/init.lua index 0fdfaa2..3b40caa 100644 --- a/config/nvim/lua/custom/plugins/init.lua +++ b/config/nvim/lua/custom/plugins/init.lua @@ -144,4 +144,124 @@ return { } end, }, + { + 'yetone/avante.nvim', + event = 'VeryLazy', + lazy = false, + version = false, + opts = { + provider = 'claude', + auto_suggestion_provider = 'claude', + claude = { + endpoint = 'https://api.anthropic.com', + model = 'claude-3-5-sonnet-20241022', + temperature = 0, + max_tokens = 4096, + }, + behaviour = { + auto_suggestions = false, + auto_set_highlight_group = true, + aute_set_keymaps = true, + auto_apply_diff_after_generation = true, + support_paste_from_clipboard = false, + minimize_diff = true, + }, + mappings = { + diff = { + ours = 'co', + theirs = 'ct', + all_theirs = 'ca', + both = 'cb', + cursor = 'cc', + next = ']x', + prev = '[x', + }, + suggestion = { + accept = '', + next = '', + prev = '', + dismiss = '', + }, + jump = { + next = ']]', + prev = '[[', + }, + submit = { + normal = '', + insert = '', + }, + sidebar = { + apply_all = 'A', + apply_cursor = 'a', + switch_windows = '', + reverse_switch_windows = '', + }, + }, + hints = { enabled = true }, + windows = { + position = 'right', + wrap = true, + width = 30, + sidebar_header = { + enabled = true, + align = 'center', + rounded = true, + }, + input = { + prefix = '> ', + height = 8, + }, + edit = { + border = 'rounded', + start_insert = true, + }, + ask = { + floating = false, + start_insert = true, + border = 'rounded', + focus_on_apply = 'ours', + }, + }, + highlights = { + diff = { + current = 'DiffText', + incoming = 'DiffAdd', + }, + }, + diff = { + autojump = true, + list_opener = 'copen', + override_timeoutlen = 500, + }, + }, + build = 'make', + dependencies = { + 'stevearc/dressing.nvim', + 'nvim-lua/plenary.nvim', + 'MunifTanjim/nui.nvim', + 'hrsh7th/nvim-cmp', + 'nvim-tree/nvim-web-devicons', + { + 'HakonHarnes/img-clip.nvim', + event = 'VeryLazy', + opts = { + default = { + embed_image_as_base64 = false, + prompt_for_file_name = false, + drag_and_drop = { + insert_mode = true, + }, + use_absolute_path = true, + }, + }, + }, + { + 'MeanderingProgrammer/render-markdown.nvim', + opts = { + file_types = { 'markdown', 'Avante' }, + }, + ft = { 'markdown', 'Avante' }, + }, + }, + }, } diff --git a/docker-compose.yml b/docker-compose.yml index 2888639..8dd6d8d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,13 +1,20 @@ --- services: nvim: - build: . + build: + context: . + args: + GIT_USER_EMAIL: ${NVIM_GIT_USER_EMAIL:-nobody@example.com} + GIT_USER_NAME: ${NVIM_GIT_USER_NAME:-noboby} image: 'joaodubas/nvim:${NVIM_TAG:-latest}' init: true restart: unless-stopped hostname: local entrypoint: sleep command: infinity + environment: + ANTHROPIC_API_KEY: ${NVIM_ANTHROPIC_API_KEY:-no-api} + GH_TOKEN: ${NVIM_GH_TOKEN:-no-token} volumes: - './config/atuin:/home/coder/.config/atuin' - './config/git:/home/coder/.config/git' diff --git a/patch/kickstart.nvim/updates.patch b/patch/kickstart.nvim/updates.patch index bcaf05a..2fe1aaa 100644 --- a/patch/kickstart.nvim/updates.patch +++ b/patch/kickstart.nvim/updates.patch @@ -1,5 +1,5 @@ diff --git a/init.lua b/init.lua -index ea86b79..7323a7f 100644 +index 08717d5..96c1e03 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' @@ -39,7 +39,7 @@ index ea86b79..7323a7f 100644 -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` -@@ -618,6 +626,27 @@ require('lazy').setup({ +@@ -628,6 +636,27 @@ require('lazy').setup({ -- ts_ls = {}, -- @@ -67,7 +67,7 @@ index ea86b79..7323a7f 100644 lua_ls = { -- cmd = {...}, -- filetypes = { ...}, -@@ -632,6 +661,32 @@ require('lazy').setup({ +@@ -642,6 +671,32 @@ require('lazy').setup({ }, }, }, @@ -100,7 +100,7 @@ index ea86b79..7323a7f 100644 } -- Ensure the servers and tools above are installed -@@ -658,6 +713,33 @@ require('lazy').setup({ +@@ -668,6 +723,33 @@ require('lazy').setup({ -- by the server configuration above. Useful when disabling -- certain features of an LSP (for example, turning off formatting for ts_ls) server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) @@ -134,7 +134,7 @@ index ea86b79..7323a7f 100644 require('lspconfig')[server_name].setup(server) end, }, -@@ -888,7 +970,39 @@ require('lazy').setup({ +@@ -898,7 +980,39 @@ require('lazy').setup({ main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { @@ -175,7 +175,7 @@ index ea86b79..7323a7f 100644 -- Autoinstall languages that are not installed auto_install = true, highlight = { -@@ -918,18 +1032,18 @@ require('lazy').setup({ +@@ -928,17 +1042,17 @@ require('lazy').setup({ -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- -- require 'kickstart.plugins.debug', @@ -191,9 +191,8 @@ index ea86b79..7323a7f 100644 -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, - }, { - ui = { - -- If you are using a Nerd Font: set icons to an empty table which will use the + -- + -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` + -- Or use telescope!