From 36df2834e574f38f2b906b42234a1dbeb53b3d1d Mon Sep 17 00:00:00 2001 From: Simon Lasbrugnas Date: Wed, 15 Nov 2023 06:38:23 +0100 Subject: [PATCH] feat: update nvim plugins and configurations Update Neovim plugins and keybindings for an improved development experience . Changes include the addition of `toggleterm.nvim` for better terminal support , `conform.nvim` for easier configurations, new themes, AI assistance with ` neoai.nvim`, version control enhancements, and more. Removed unused themes and plugins to streamline the setup. Refactored keybindings for better navigation and usability. ChatGPT is taking its job seriously --- after/plugin/cloak.lua | 22 ----------- after/plugin/comment.lua | 1 - after/plugin/conform.lua | 3 ++ after/plugin/lsp.lua | 2 +- after/plugin/lualine.lua | 6 +++ after/plugin/mini.lua | 4 ++ after/plugin/neoai.lua | 33 +++++++++++++--- after/plugin/nvim-tree.lua | 61 ++++++++++++++++++++++++++++- after/plugin/telescope.lua | 3 +- after/plugin/toggleterm.lua | 4 ++ lua/default/packer.lua | 78 ++++++++++++++++++++----------------- lua/default/remap.lua | 45 ++++----------------- 12 files changed, 156 insertions(+), 106 deletions(-) delete mode 100644 after/plugin/cloak.lua delete mode 100644 after/plugin/comment.lua create mode 100644 after/plugin/conform.lua create mode 100644 after/plugin/lualine.lua create mode 100644 after/plugin/mini.lua create mode 100644 after/plugin/toggleterm.lua diff --git a/after/plugin/cloak.lua b/after/plugin/cloak.lua deleted file mode 100644 index 3addbb6..0000000 --- a/after/plugin/cloak.lua +++ /dev/null @@ -1,22 +0,0 @@ -require("cloak").setup({ - enabled = false, - cloak_character = "*", - -- The applied highlight group (colors) on the cloaking, see `:h highlight`. - highlight_group = "Comment", - patterns = { - { - -- Match any file starting with ".env". - -- This can be a table to match multiple file patterns. - file_pattern = { - ".env*", - "wrangler.toml", - ".dev.vars", - }, - -- Match an equals sign and any character after it. - -- This can also be a table of patterns to cloak, - -- example: cloak_pattern = { ":.+", "-.+" } for yaml files. - cloak_pattern = "=.+" - }, - }, -}) - diff --git a/after/plugin/comment.lua b/after/plugin/comment.lua deleted file mode 100644 index a844323..0000000 --- a/after/plugin/comment.lua +++ /dev/null @@ -1 +0,0 @@ -require('Comment').setup() diff --git a/after/plugin/conform.lua b/after/plugin/conform.lua new file mode 100644 index 0000000..ed4ed1b --- /dev/null +++ b/after/plugin/conform.lua @@ -0,0 +1,3 @@ +require("conform").setup{ + javascript = { { "prettierd", "prettier" } }, +} diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index 65581b8..6fa3007 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -2,7 +2,7 @@ local lsp = require("lsp-zero") local lspconfig = require('lspconfig') local home = vim.fn.expand('$HOME') --- Activate intelephense +-- Activate intelephense because I paid for it, yes lspconfig.intelephense.setup { cmd = { "intelephense", "--stdio" }, settings = { diff --git a/after/plugin/lualine.lua b/after/plugin/lualine.lua new file mode 100644 index 0000000..59656d8 --- /dev/null +++ b/after/plugin/lualine.lua @@ -0,0 +1,6 @@ +require('lualine').setup{ + options = { + theme = 'auto', + icons_enabled = true, + }, +} diff --git a/after/plugin/mini.lua b/after/plugin/mini.lua new file mode 100644 index 0000000..1d72b43 --- /dev/null +++ b/after/plugin/mini.lua @@ -0,0 +1,4 @@ +require('mini.comment').setup() +require('mini.surround').setup() +require('mini.pairs').setup() +require('mini.clue').setup() diff --git a/after/plugin/neoai.lua b/after/plugin/neoai.lua index b4ee8cb..03e27d2 100644 --- a/after/plugin/neoai.lua +++ b/after/plugin/neoai.lua @@ -1,4 +1,4 @@ -require("neoai").setup({ +require('neoai').setup({ models = { { name = "openai", @@ -8,8 +8,6 @@ require("neoai").setup({ }, open_ai = { api_key = { - env = "OPENAI_API_KEY", - value = nil, get = function() local key = vim.fn.system("pass show openai/api_key") key = string.gsub(key, "\n", "") @@ -17,6 +15,16 @@ require("neoai").setup({ end, }, }, + prompts = { + context_prompt = function(context) + return "You are a senior software developer." + .. "You always answer question with short, straight to the point answers." + .. "You only provide the code snippet and without the code block." + .. "Only provide explaination if the user asks for it" + .. "Here is the user's problem:" + .. context + end, + }, shortcuts = { { name = "textify", @@ -62,9 +70,8 @@ require("neoai").setup({ ========================================= ci: use pulumi common new kubernetes helpers ========================================= - Using the following git diff generate a consise and - clear git commit message, with a short title summary - that is 75 characters or less. + Using the following git diff in order to generate + a consise and clear git commit message: ]] .. vim.fn.system("git diff --cached") end, modes = { "n" }, @@ -72,3 +79,17 @@ require("neoai").setup({ }, }, }) + +-- Keybindings +vim.keymap.set("n", "at", "NeoAIToggle", + {silent = true, noremap = true} +) +vim.keymap.set("n", "ai", ":NeoAIInject YOUR MAY ONLY PROVIDE ONLY THE CODE SNIPPET AND WITHOUT THE CODE BLOCK", + {silent = true, noremap = true} +) +vim.keymap.set("v", "ac", "'<,'>NeoAIContextiPlease explain shortly", + {silent = true, noremap = true} +) +vim.keymap.set("n", "ap", "put clet @c=''", + {silent = true, noremap = true} +) diff --git a/after/plugin/nvim-tree.lua b/after/plugin/nvim-tree.lua index 26fa3fc..609b29a 100644 --- a/after/plugin/nvim-tree.lua +++ b/after/plugin/nvim-tree.lua @@ -1,6 +1,65 @@ require("nvim-tree").setup({ sort_by = "case_sensitive", view = { width = 40, }, - renderer = { group_empty = true, }, filters = { dotfiles = true, }, + actions = { + open_file = { + quit_on_open = true, + }, + }, + renderer = { + group_empty = true, + icons = { + web_devicons = { + file = { + enable = true, + color = true, + }, + folder = { + enable = false, + color = true, + }, + }, + git_placement = "before", + modified_placement = "after", + diagnostics_placement = "signcolumn", + bookmarks_placement = "signcolumn", + padding = " ", + symlink_arrow = " ➛ ", + show = { + file = true, + folder = true, + folder_arrow = true, + git = true, + modified = true, + diagnostics = true, + bookmarks = true, + }, + glyphs = { + default = "", + symlink = "", + bookmark = "󰆤", + modified = "●", + folder = { + arrow_closed = "", + arrow_open = "", + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + symlink_open = "", + }, + git = { + unstaged = "✗", + staged = "✓", + unmerged = "", + renamed = "➜", + untracked = "★", + deleted = "", + ignored = "◌", + }, + }, + }, + }, }) diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua index fe289fc..036d331 100644 --- a/after/plugin/telescope.lua +++ b/after/plugin/telescope.lua @@ -23,6 +23,5 @@ vim.keymap.set('n', 'ps', function() builtin.live_grep() end) vim.keymap.set('n', 'vh', builtin.help_tags, {}) vim.keymap.set('n', 'fa', function() builtin.find_files({ follow = true, no_ignore = true, hidden = true }) end) vim.keymap.set('n', 'fb', function() builtin.buffers() end) -vim.keymap.set('n', 'cm', function() builtin.git_commits() end) +vim.keymap.set('n', 'fc', function() builtin.git_commits() end) vim.keymap.set('n', 'gt', function() builtin.git_status() end) - diff --git a/after/plugin/toggleterm.lua b/after/plugin/toggleterm.lua new file mode 100644 index 0000000..4f95110 --- /dev/null +++ b/after/plugin/toggleterm.lua @@ -0,0 +1,4 @@ +require("toggleterm").setup() + +-- floating terminal +vim.keymap.set("n", "\\", "ToggleTerm direction=float") diff --git a/lua/default/packer.lua b/lua/default/packer.lua index c65f9b3..df3a512 100644 --- a/lua/default/packer.lua +++ b/lua/default/packer.lua @@ -1,31 +1,38 @@ --- This file can be loaded by calling `lua require('plugins')` from your init.vim - --- Only required if you have packer configured as `opt` vim.cmd.packadd("packer.nvim") return require("packer").startup(function(use) -- Packer can manage itself use "wbthomason/packer.nvim" + -- gF but better (and real) use "wsdjeg/vim-fetch" + -- terminal in neovim which already exists but is pretty bad and this one is better + use { "akinsho/toggleterm.nvim", tag = '*' } + + -- find everything, maybe too much use { "nvim-telescope/telescope.nvim", - requires = { {"nvim-lua/plenary.nvim"} } + requires = { { "nvim-lua/plenary.nvim" } } } - use 'numToStr/Comment.nvim' - - use("tpope/vim-surround") + -- easy mode + use("stevearc/conform.nvim") + use { 'stevearc/dressing.nvim' } + use("rafamadriz/friendly-snippets") + use({ 'echasnovski/mini.nvim', branch = 'stable' }) + use("ThePrimeagen/refactoring.nvim") + -- theme stuff + use { + 'nvim-lualine/lualine.nvim', + requires = { 'nvim-tree/nvim-web-devicons', opt = true } + } use("rebelot/kanagawa.nvim") use("felipeagc/fleet-theme-nvim") - use { "catppuccin/nvim", as = "catppuccin" } - use({ 'rose-pine/neovim', as = 'rose-pine' }) - use("folke/tokyonight.nvim") - use("lukas-reineke/indent-blankline.nvim") + -- do I need this ? use({ "folke/trouble.nvim", config = function() @@ -35,6 +42,7 @@ return require("packer").startup(function(use) end }) + -- I'm not a netrw fan use { 'nvim-tree/nvim-tree.lua', requires = { @@ -42,10 +50,6 @@ return require("packer").startup(function(use) }, } - use("lewis6991/gitsigns.nvim") - - use("ThePrimeagen/refactoring.nvim") - use { "nvim-treesitter/nvim-treesitter", run = function() @@ -53,47 +57,51 @@ return require("packer").startup(function(use) ts_update() end } - + use("nvim-treesitter/nvim-treesitter-context"); use("nvim-treesitter/playground") + + -- versionning use("mbbill/undotree") use("tpope/vim-fugitive") - use("nvim-treesitter/nvim-treesitter-context"); - use("jacoborus/tender.vim") + use("lewis6991/gitsigns.nvim") + -- important + use("folke/zen-mode.nvim") + use("eandrju/cellular-automaton.nvim") + + -- AI stuff + use("github/copilot.vim") use { "Bryley/neoai.nvim", requires = { "MunifTanjim/nui.nvim", } } + + -- making neovim actually usable use { "VonHeikemen/lsp-zero.nvim", branch = 'v1.x', requires = { -- LSP Support - {"neovim/nvim-lspconfig"}, - {"williamboman/mason.nvim"}, - {"williamboman/mason-lspconfig.nvim"}, + { "neovim/nvim-lspconfig" }, + { "williamboman/mason.nvim" }, + { "williamboman/mason-lspconfig.nvim" }, -- Autocompletion - {"hrsh7th/nvim-cmp"}, - {"hrsh7th/cmp-buffer"}, - {"hrsh7th/cmp-path"}, - {"saadparwaiz1/cmp_luasnip"}, - {"hrsh7th/cmp-nvim-lsp"}, - {"hrsh7th/cmp-nvim-lua"}, + { "hrsh7th/nvim-cmp" }, + { "hrsh7th/cmp-buffer" }, + { "hrsh7th/cmp-path" }, + { "saadparwaiz1/cmp_luasnip" }, + { "hrsh7th/cmp-nvim-lsp" }, + { "hrsh7th/cmp-nvim-lua" }, -- Snippets - {"L3MON4D3/LuaSnip"}, - {"rafamadriz/friendly-snippets"}, + { "L3MON4D3/LuaSnip" }, + { "rafamadriz/friendly-snippets" }, -- Colors - {"folke/lsp-colors.nvim"}, + { "folke/lsp-colors.nvim" }, } } - - use("folke/zen-mode.nvim") - use("github/copilot.vim") - use("eandrju/cellular-automaton.nvim") - use("laytan/cloak.nvim") end) diff --git a/lua/default/remap.lua b/lua/default/remap.lua index 1d7b0bc..8d17fbf 100755 --- a/lua/default/remap.lua +++ b/lua/default/remap.lua @@ -10,16 +10,13 @@ vim.keymap.set("n", "", "zz") vim.keymap.set("n", "n", "nzzzv") vim.keymap.set("n", "N", "Nzzzv") --- greatest remap ever vim.keymap.set("x", "p", [["_dP]]) --- next greatest remap ever : asbjornHaland vim.keymap.set({"n", "v"}, "y", [["+y]]) vim.keymap.set("n", "Y", [["+Y]]) vim.keymap.set({"n", "v"}, "d", [["_d]]) --- This is going to get me cancelled vim.keymap.set("i", "", "") vim.keymap.set("n", "Q", "") @@ -38,14 +35,17 @@ vim.keymap.set("n", "", function() vim.cmd("so") end) --- Keybindings for navigating tabs -vim.keymap.set("n", ".", function() +-- get out of terminal mode +vim.keymap.set("t", "", "") + +-- tab stuff +vim.keymap.set("n", "tn", function() vim.cmd("tabn") end, {}) vim.keymap.set("n", "", function() vim.cmd("tabn") end, {}) -vim.keymap.set("n", ",", function() +vim.keymap.set("n", "tp", function() vim.cmd("tabp") end, {}) vim.keymap.set("n", "tc", function() @@ -54,19 +54,11 @@ end, {}) vim.keymap.set("n", "tt", function() vim.cmd("tabnew") end, {}) -vim.keymap.set("n", "<", function() - vim.cmd("tabfirst") -end, {}) -vim.keymap.set("n", ">", function() - vim.cmd("tablast") -end, {}) --- Keybinding for deleting the current buffer using :bd +-- buffer stuff vim.keymap.set("n", "bd", function() vim.cmd("bd") end, {}) - --- Keybding for cycling through the list of buffers vim.keymap.set("n", "bn", function() vim.cmd("bn") end, {}) @@ -74,26 +66,3 @@ vim.keymap.set("n", "bp", function() vim.cmd("bp") end, {}) --- Define a function to execute the appropriate program based on file type -vim.keymap.set("n", "/", function() - local filetype = vim.bo.filetype - local app = "" - if filetype == "javascript" then - app = "node" - elseif filetype == "typescript" then - app = "ts-node" - elseif filetype == "lua" then - app = "lua" - elseif filetype == "python" then - app = "python" - elseif filetype == "rust" then - app = "cargo run" - elseif filetype == "go" then - app = "go run" - else - print("Unsupported file type: " .. filetype) - return - end - vim.cmd("terminal " .. app .. " %") -end, { noremap = true, silent = true }) -