From 9847dc9fabad31964243bdb42c7b772869aaa836 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 31 Aug 2024 15:32:24 +0100 Subject: [PATCH 01/16] Rewrite init.vim to init.lua --- config/home.nix | 3 +- config/packages/neovim/default.nix | 2 +- config/packages/neovim/init.lua | 242 +++++++++++++++++++++++++++++ config/packages/neovim/init.vim | 143 ----------------- 4 files changed, 245 insertions(+), 145 deletions(-) create mode 100644 config/packages/neovim/init.lua delete mode 100644 config/packages/neovim/init.vim diff --git a/config/home.nix b/config/home.nix index b6c597e..fe43bf9 100644 --- a/config/home.nix +++ b/config/home.nix @@ -96,7 +96,8 @@ in { tldr unzip vim - vimPlugins.vim-plug + vimPlugins.vim-packer + vimPlugins.packer-nvim virtio-win vscode wget diff --git a/config/packages/neovim/default.nix b/config/packages/neovim/default.nix index 4480ef2..dc0b484 100644 --- a/config/packages/neovim/default.nix +++ b/config/packages/neovim/default.nix @@ -1,4 +1,4 @@ { - home.file."/home/vylpes/.config/nvim/init.vim".source = ./init.vim; + home.file."/home/vylpes/.config/nvim/init.lua".source = ./init.lua; home.file."/home/vylpes/.config/nvim/coc-settings.json".source = ./coc-settings.json; } diff --git a/config/packages/neovim/init.lua b/config/packages/neovim/init.lua new file mode 100644 index 0000000..d188436 --- /dev/null +++ b/config/packages/neovim/init.lua @@ -0,0 +1,242 @@ +-- Leader key +vim.g.mapleader = " " + +-- Disable Copilot by default +vim.g.copilot_enabled = false + +-- Basic settings +vim.opt.compatible = false +vim.opt.showmatch = true +vim.opt.ignorecase = true +vim.opt.mouse = "v" +vim.opt.hlsearch = true +vim.opt.incsearch = true + +-- Tab and indentation settings +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.expandtab = true +vim.opt.shiftwidth = 4 +vim.opt.autoindent = true + +-- Line numbering +vim.opt.number = true +vim.opt.relativenumber = true + +-- Command-line completion mode +vim.opt.wildmode = { "longest", "list" } + +-- Column marker at 80 characters +vim.opt.colorcolumn = "80" + +-- Enable filetype plugins and indentation +vim.cmd("filetype plugin indent on") + +-- Enable syntax highlighting +vim.cmd("syntax on") + +-- Enable mouse support +vim.opt.mouse = "a" + +-- Use system clipboard +vim.opt.clipboard = "unnamedplus" + +-- Enable cursorline +vim.opt.cursorline = true + +-- Optimize for fast terminal +vim.opt.ttyfast = true + +-- Do not add a newline at the end of the file +vim.opt.fixeol = false + +local data_dir = vim.fn.has('nvim') == 1 and vim.fn.stdpath('data') .. '/site' or '~/.vim' + +if vim.fn.empty(vim.fn.glob(data_dir .. '/autoload/plug.vim')) == 1 then + vim.fn.system({ + 'curl', '-fLo', data_dir .. '/autoload/plug.vim', '--create-dirs', + 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + }) + vim.cmd('autocmd VimEnter * PlugInstall --sync | source $MYVIMRC') +end + +-- Initialize packer.nvim +vim.cmd [[packadd packer.nvim]] + +return require('packer').startup(function(use) + -- Packer can manage itself + use 'wbthomason/packer.nvim' + + -- Plugins + use 'dracula/vim' + use 'ryanoasis/vim-devicons' + -- use 'SirVer/ultisnips' + use 'honza/vim-snippets' + use 'scrooloose/nerdtree' + use 'preservim/nerdcommenter' + use 'mhinz/vim-startify' + use {'neoclide/coc.nvim', branch = 'release'} + use 'nvim-lua/plenary.nvim' + use 'ThePrimeagen/harpoon' + use {'junegunn/fzf', run = function() vim.fn['fzf#install']() end} + use 'junegunn/fzf.vim' + use 'neovim/nvim-lspconfig' + use 'jose-elias-alvarez/null-ls.nvim' + use 'MunifTanjim/prettier.nvim' + use 'github/copilot.vim' + use {'CopilotC-Nvim/CopilotChat.nvim', branch = 'canary'} +end) + +-- Copilot Chat +local prompts = require('CopilotChat.prompts') +local select = require('CopilotChat.select') + +require("CopilotChat").setup { + debug = false, + + question_header = '## User ', + answer_header = '## Copilot ', + error_header = '## Error ', + separator = '---', + + selection = function(source) + return select.visual(source) or select.line(source) + end, + + window = { + layout = 'float', + }, +} + +if vim.fn.has("termguicolors") == 1 then + vim.opt.termguicolors = true +end + +-- Enable syntax highlighting +vim.cmd("syntax enable") + +-- Set colorscheme to dracula +vim.cmd("colorscheme dracula") + +-- Open new vertical splits to the right +vim.opt.splitright = true + +-- Open new horizontal splits below +vim.opt.splitbelow = true + +-- Insert mode mappings +vim.api.nvim_set_keymap('i', '', ':m .+1==gi', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('i', '', ':m .-2==gi', { noremap = true, silent = true }) + +-- Visual mode mappings +vim.api.nvim_set_keymap('v', '', ":m '>+1gv=gv", { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', '', ":m '<-2gv=gv", { noremap = true, silent = true }) + +-- Normal mode mappings for window movement +vim.api.nvim_set_keymap('n', '', 'H', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'J', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'K', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'L', { noremap = true, silent = true }) + +-- Normal mode mappings for window navigation +vim.api.nvim_set_keymap('n', '', 'h', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'j', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'k', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'l', { noremap = true, silent = true }) + +-- Normal mode mapping for opening file in vertical split +vim.api.nvim_set_keymap('n', 'gf', ':vert winc f', { noremap = true, silent = true }) + +-- Insert mode mappings for CoC (Conquer of Completion) +vim.api.nvim_set_keymap('i', '', [[coc#pum#visible() ? coc#_select_confirm() : "\u\"]], { noremap = true, silent = true, expr = true }) +vim.api.nvim_set_keymap('i', '', [[coc#pum#visible() ? coc#pum#next(1) : "\"]], { noremap = true, silent = true, expr = true }) +vim.api.nvim_set_keymap('i', '', [[coc#pum#visible() ? coc#pum#prev(1) : "\"]], { noremap = true, silent = true, expr = true }) + +-- Normal mode mappings for NERDTree +vim.api.nvim_set_keymap('n', 'n', ':NERDTreeFocus', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', ':NERDTree', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', ':NERDTreeToggle', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', ':NERDTreeFind', { noremap = true, silent = true }) + +-- Normal mode mapping for opening file explorer +vim.api.nvim_set_keymap('n', 'ee', ':Ex', { noremap = true, silent = true }) + +-- Harpoon mappings +vim.api.nvim_set_keymap('n', 'ha', 'lua require("harpoon.mark").add_file()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'hh', 'lua require("harpoon.ui").toggle_quick_menu()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '1', 'lua require("harpoon.ui").nav_file(1)', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '2', 'lua require("harpoon.ui").nav_file(2)', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '3', 'lua require("harpoon.ui").nav_file(3)', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '4', 'lua require("harpoon.ui").nav_file(4)', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'lua require("harpoon.ui").nav_prev()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'lua require("harpoon.ui").nav_next()', { noremap = true, silent = true }) + +-- FZF mapping +vim.api.nvim_set_keymap('n', 'ff', ':FZF', { noremap = true, silent = true }) + +-- Miscellaneous mappings +vim.api.nvim_set_keymap('n', 'mm', ':nohl', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'ml', ':%s/\\r//g', { noremap = true, silent = true }) + +-- Yarn mappings +vim.api.nvim_set_keymap('n', 'yb', ':!yarn build', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'yi', ':!yarn install', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'ys', ':!yarn start', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'yt', ':!yarn test', { noremap = true, silent = true }) + +-- Dotnet mapping +vim.api.nvim_set_keymap('n', 'dr', ':!dotnet run', { noremap = true, silent = true }) + +-- Prettier mapping +vim.api.nvim_set_keymap('n', 'p', '(prettier-format)', { noremap = true, silent = true }) + +-- Copilot Chat mappings +vim.api.nvim_set_keymap('n', '', ':CopilotChatToggle', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'ps', ':CopilotChatStop', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'pr', ':CopilotChatReset', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', 'pe', ':CopilotChatExplain', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', 'pr', ':CopilotChatReview', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', 'pf', ':CopilotChatFix', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', 'po', ':CopilotChatOptimize', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', 'pd', ':CopilotChatDocs', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', 'pt', ':CopilotChatTests', { noremap = true, silent = true }) + +-- Harpoon mappings +vim.api.nvim_set_keymap('n', 'ha', 'lua require("harpoon.mark").add_file()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'hh', 'lua require("harpoon.ui").toggle_quick_menu()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '1', 'lua require("harpoon.ui").nav_file(1)', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '2', 'lua require("harpoon.ui").nav_file(2)', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '3', 'lua require("harpoon.ui").nav_file(3)', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '4', 'lua require("harpoon.ui").nav_file(4)', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'lua require("harpoon.ui").nav_prev()', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', '', 'lua require("harpoon.ui").nav_next()', { noremap = true, silent = true }) + +-- FZF mapping +vim.api.nvim_set_keymap('n', 'ff', ':FZF', { noremap = true, silent = true }) + +-- Miscellaneous mappings +vim.api.nvim_set_keymap('n', 'mm', ':nohl', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'ml', ':%s/\\r//g', { noremap = true, silent = true }) + +-- Yarn mappings +vim.api.nvim_set_keymap('n', 'yb', ':!yarn build', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'yi', ':!yarn install', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'ys', ':!yarn start', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'yt', ':!yarn test', { noremap = true, silent = true }) + +-- Dotnet mapping +vim.api.nvim_set_keymap('n', 'dr', ':!dotnet run', { noremap = true, silent = true }) + +-- Prettier mapping +vim.api.nvim_set_keymap('n', 'p', '(prettier-format)', { noremap = true, silent = true }) + +-- Copilot mappings +vim.api.nvim_set_keymap('n', '', ':CopilotChatToggle', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'ps', ':CopilotChatStop', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'pr', ':CopilotChatReset', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', 'pe', ':CopilotChatExplain', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', 'pr', ':CopilotChatReview', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', 'pf', ':CopilotChatFix', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', 'po', ':CopilotChatOptimize', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', 'pd', ':CopilotChatDocs', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', 'pt', ':CopilotChatTests', { noremap = true, silent = true }) diff --git a/config/packages/neovim/init.vim b/config/packages/neovim/init.vim deleted file mode 100644 index 32d91e7..0000000 --- a/config/packages/neovim/init.vim +++ /dev/null @@ -1,143 +0,0 @@ -let mapleader = " " -let g:copilot_enabled = v:false - -set nocompatible -set showmatch -set ignorecase -set mouse=v -set hlsearch -set incsearch -set tabstop=4 -set softtabstop=4 -set expandtab -set shiftwidth=4 -set autoindent -set number -set relativenumber -set wildmode=longest,list -set cc=80 -filetype plugin indent on -syntax on -set mouse=a -set clipboard=unnamedplus -filetype plugin on -set cursorline -set ttyfast -set nofixeol - -let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' -if empty(glob(data_dir . '/autoload/plug.vim')) - silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' - autocmd VimEnter * PlugInstall --sync | source $MYVIMRC -endif - -call plug#begin("~/.vim/plugged") - Plug 'dracula/vim' - Plug 'ryanoasis/vim-devicons' - " Plug 'SirVer/ultisnips' - Plug 'honza/vim-snippets' - Plug 'scrooloose/nerdtree' - Plug 'preservim/nerdcommenter' - Plug 'mhinz/vim-startify' - Plug 'neoclide/coc.nvim', {'branch': 'release'} - Plug 'nvim-lua/plenary.nvim' - Plug 'ThePrimeagen/harpoon' - Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } - Plug 'junegunn/fzf.vim' - Plug 'neovim/nvim-lspconfig' - Plug 'jose-elias-alvarez/null-ls.nvim' - Plug 'MunifTanjim/prettier.nvim' - Plug 'github/copilot.vim' - Plug 'CopilotC-Nvim/CopilotChat.nvim', { 'branch': 'canary' } -call plug#end() - -lua << EOF -local prompts = require('CopilotChat.prompts') -local select = require('CopilotChat.select') - -require("CopilotChat").setup { - debug = false, - - question_header = '## User ', - answer_header = '## Copilot ', - error_header = '## Error ', - separator = '---', - - selection = function(source) - return select.visual(source) or select.line(source) - end, - - window = { - layout = 'float', - }, -} -EOF - -if (has("termguicolors")) - set termguicolors -endif -syntax enable -colorscheme dracula - -set splitright -set splitbelow - -inoremap :m .+1==gi -inoremap :m .-2==gi -vnoremap :m '>+1gv=gv -vnoremap :m '<-2gv=gv - -nnoremap H -nnoremap J -nnoremap K -nnoremap L - -nnoremap h -nnoremap j -nnoremap k -nnoremap l - -nnoremap gf :vert winc f - -inoremap coc#pum#visible() ? coc#_select_confirm() : "\u\" -inoremap coc#pum#visible() ? coc#pum#next(1) : "\" -inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" - -nnoremap n :NERDTreeFocus -nnoremap :NERDTree -nnoremap :NERDTreeToggle -nnoremap :NERDTreeFind -nnoremap ee :Ex - -nnoremap ha lua require("harpoon.mark").add_file() -nnoremap hh lua require("harpoon.ui").toggle_quick_menu() -nnoremap 1 lua require("harpoon.ui").nav_file(1) -nnoremap 2 lua require("harpoon.ui").nav_file(2) -nnoremap 3 lua require("harpoon.ui").nav_file(3) -nnoremap 4 lua require("harpoon.ui").nav_file(4) -nnoremap lua require("harpoon.ui").nav_prev() -nnoremap lua require("harpoon.ui").nav_next() - -nnoremap ff :FZF - -nnoremap mm :nohl -nnoremap ml :%s/\r//g - -nnoremap yb :!yarn build -nnoremap yi :!yarn install -nnoremap ys :!yarn start -nnoremap yt :!yarn test - -nnoremap dr :!dotnet run - -nnoremap p (prettier-format) - -nnoremap :CopilotChatToggle -nnoremap ps :CopilotChatStop -nnoremap pr :CopilotChatReset -vnoremap pe :CopilotChatExplain -vnoremap pr :CopilotChatReview -vnoremap pf :CopilotChatFix -vnoremap po :CopilotChatOptimize -vnoremap pd :CopilotChatDocs -vnoremap pt :CopilotChatTests From 49f378d5a35df54509a089058881287b2371d16e Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 21 Sep 2024 13:50:06 +0100 Subject: [PATCH 02/16] Nix flake update --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 992c919..54ad83d 100644 --- a/flake.lock +++ b/flake.lock @@ -23,11 +23,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1726688310, - "narHash": "sha256-Xc9lEtentPCEtxc/F1e6jIZsd4MPDYv4Kugl9WtXlz0=", + "lastModified": 1726838390, + "narHash": "sha256-NmcVhGElxDbmEWzgXsyAjlRhUus/nEqPC5So7BOJLUM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "dbebdd67a6006bb145d98c8debf9140ac7e651d0", + "rev": "944b2aea7f0a2d7c79f72468106bc5510cbf5101", "type": "github" }, "original": { From 33b86325aa6812aa7cd6fec324bdd863adba22b7 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 21 Sep 2024 13:51:44 +0100 Subject: [PATCH 03/16] Remove conflict maybe --- config/home.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/config/home.nix b/config/home.nix index 1f75dab..61a3475 100644 --- a/config/home.nix +++ b/config/home.nix @@ -102,7 +102,6 @@ in { tldr unzip vim - vimPlugins.vim-packer vimPlugins.packer-nvim virtio-win vscode From c6669af194184d569c966b87aa24d0f4101651cc Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 21 Sep 2024 13:56:26 +0100 Subject: [PATCH 04/16] Try other package --- config/home.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/home.nix b/config/home.nix index 61a3475..87a1f37 100644 --- a/config/home.nix +++ b/config/home.nix @@ -102,7 +102,7 @@ in { tldr unzip vim - vimPlugins.packer-nvim + vimPlugins.vim-packer virtio-win vscode wget From f4149d4d2f9403b2385479d9c4de239a784a4de2 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 21 Sep 2024 14:03:20 +0100 Subject: [PATCH 05/16] Setup packer --- config/packages/neovim/init.lua | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/config/packages/neovim/init.lua b/config/packages/neovim/init.lua index d188436..3cde446 100644 --- a/config/packages/neovim/init.lua +++ b/config/packages/neovim/init.lua @@ -52,16 +52,27 @@ vim.opt.fixeol = false local data_dir = vim.fn.has('nvim') == 1 and vim.fn.stdpath('data') .. '/site' or '~/.vim' -if vim.fn.empty(vim.fn.glob(data_dir .. '/autoload/plug.vim')) == 1 then - vim.fn.system({ - 'curl', '-fLo', data_dir .. '/autoload/plug.vim', '--create-dirs', - 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' - }) - vim.cmd('autocmd VimEnter * PlugInstall --sync | source $MYVIMRC') +-- Ensure packer is installed +local install_path = vim.fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' +if vim.fn.empty(vim.fn.glob(install_path)) > 0 then + vim.fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) + vim.cmd [[packadd packer.nvim]] end --- Initialize packer.nvim -vim.cmd [[packadd packer.nvim]] +-- Use a protected call so we don't error out on first use +local status_ok, packer = pcall(require, "packer") +if not status_ok then + return +end + +-- Have packer use a popup window +packer.init { + display = { + open_fn = function() + return require('packer.util').float { border = 'rounded' } + end, + }, +} return require('packer').startup(function(use) -- Packer can manage itself @@ -86,6 +97,7 @@ return require('packer').startup(function(use) use 'github/copilot.vim' use {'CopilotC-Nvim/CopilotChat.nvim', branch = 'canary'} end) +vim.cmd [[packadd packer.nvim]] -- Copilot Chat local prompts = require('CopilotChat.prompts') From 89c34c76892122c946ad792eac3b9c01e3c0873b Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 21 Sep 2024 14:03:33 +0100 Subject: [PATCH 06/16] Remove package --- config/home.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/config/home.nix b/config/home.nix index 87a1f37..9672dcd 100644 --- a/config/home.nix +++ b/config/home.nix @@ -102,7 +102,6 @@ in { tldr unzip vim - vimPlugins.vim-packer virtio-win vscode wget From bc8b0d5adc4b9b12b6068f871cfbc873f650a4ca Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 21 Sep 2024 14:09:16 +0100 Subject: [PATCH 07/16] Install vimplugin --- config/packages/neovim/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/config/packages/neovim/default.nix b/config/packages/neovim/default.nix index dc0b484..a69ed38 100644 --- a/config/packages/neovim/default.nix +++ b/config/packages/neovim/default.nix @@ -1,4 +1,11 @@ { home.file."/home/vylpes/.config/nvim/init.lua".source = ./init.lua; home.file."/home/vylpes/.config/nvim/coc-settings.json".source = ./coc-settings.json; + + programs.neovim = { + enable = true; + plugins = with pkgs.vimPlugins; [ + packer-nvim + ]; + }; } From 6b8ee077953d5a7d15f7527cce196b43a6aa7576 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 21 Sep 2024 14:11:18 +0100 Subject: [PATCH 08/16] Move vimplugin --- config/home.nix | 7 +++++++ config/packages/neovim/default.nix | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config/home.nix b/config/home.nix index 9672dcd..680397e 100644 --- a/config/home.nix +++ b/config/home.nix @@ -29,6 +29,13 @@ in { gnome-keyring.enable = true; }; + programs.neovim = { + enable = true; + plugins = with pkgs.vimPlugins; [ + packer-nvim + ]; + }; + home = { username = "${username}"; homeDirectory = "/home/${username}"; diff --git a/config/packages/neovim/default.nix b/config/packages/neovim/default.nix index a69ed38..dc0b484 100644 --- a/config/packages/neovim/default.nix +++ b/config/packages/neovim/default.nix @@ -1,11 +1,4 @@ { home.file."/home/vylpes/.config/nvim/init.lua".source = ./init.lua; home.file."/home/vylpes/.config/nvim/coc-settings.json".source = ./coc-settings.json; - - programs.neovim = { - enable = true; - plugins = with pkgs.vimPlugins; [ - packer-nvim - ]; - }; } From 1af3d8796d044bbc245a88d20182bb4f9a16dcf5 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Wed, 30 Oct 2024 11:54:17 +0000 Subject: [PATCH 09/16] Add Neoim docs for packer --- config/packages/neovim/init.lua | 25 +------------------------ docs/Neovim.md | 13 +++++++++++++ 2 files changed, 14 insertions(+), 24 deletions(-) create mode 100644 docs/Neovim.md diff --git a/config/packages/neovim/init.lua b/config/packages/neovim/init.lua index 3cde446..0ca4f94 100644 --- a/config/packages/neovim/init.lua +++ b/config/packages/neovim/init.lua @@ -50,29 +50,7 @@ vim.opt.ttyfast = true -- Do not add a newline at the end of the file vim.opt.fixeol = false -local data_dir = vim.fn.has('nvim') == 1 and vim.fn.stdpath('data') .. '/site' or '~/.vim' - --- Ensure packer is installed -local install_path = vim.fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' -if vim.fn.empty(vim.fn.glob(install_path)) > 0 then - vim.fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) - vim.cmd [[packadd packer.nvim]] -end - --- Use a protected call so we don't error out on first use -local status_ok, packer = pcall(require, "packer") -if not status_ok then - return -end - --- Have packer use a popup window -packer.init { - display = { - open_fn = function() - return require('packer.util').float { border = 'rounded' } - end, - }, -} +vim.cmd [[packadd packer.nvim]] return require('packer').startup(function(use) -- Packer can manage itself @@ -97,7 +75,6 @@ return require('packer').startup(function(use) use 'github/copilot.vim' use {'CopilotC-Nvim/CopilotChat.nvim', branch = 'canary'} end) -vim.cmd [[packadd packer.nvim]] -- Copilot Chat local prompts = require('CopilotChat.prompts') diff --git a/docs/Neovim.md b/docs/Neovim.md new file mode 100644 index 0000000..f15497f --- /dev/null +++ b/docs/Neovim.md @@ -0,0 +1,13 @@ +# Neovim + +Neovim is mostly configured in the flake, we just need to install packer +separately, although this is only required to do once. + +## Installation + +Run the following command in the terminal + +```bash +git clone --depth 1 https://github.com/wbthomason/packer.nvim\ + ~/.local/share/nvim/site/pack/packer/start/packer.nvim +``` From 3560e68e50694146edb2c133682a4726c9526ec0 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Wed, 30 Oct 2024 11:57:26 +0000 Subject: [PATCH 10/16] Remove unrequired neovim config --- config/home.nix | 7 ------- 1 file changed, 7 deletions(-) diff --git a/config/home.nix b/config/home.nix index 95b1e3f..e2fb510 100644 --- a/config/home.nix +++ b/config/home.nix @@ -29,13 +29,6 @@ in { gnome-keyring.enable = true; }; - programs.neovim = { - enable = true; - plugins = with pkgs.vimPlugins; [ - packer-nvim - ]; - }; - home = { username = "${username}"; homeDirectory = "/home/${username}"; From baf6c92c30560162ebe0ac82c24c9d66c07498fe Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Wed, 30 Oct 2024 12:05:03 +0000 Subject: [PATCH 11/16] Add plugins.lua --- config/packages/neovim/default.nix | 1 + config/packages/neovim/init.lua | 28 ++------------------------ config/packages/neovim/lua/plugins.lua | 25 +++++++++++++++++++++++ 3 files changed, 28 insertions(+), 26 deletions(-) create mode 100644 config/packages/neovim/lua/plugins.lua diff --git a/config/packages/neovim/default.nix b/config/packages/neovim/default.nix index dc0b484..4eb8d90 100644 --- a/config/packages/neovim/default.nix +++ b/config/packages/neovim/default.nix @@ -1,4 +1,5 @@ { home.file."/home/vylpes/.config/nvim/init.lua".source = ./init.lua; home.file."/home/vylpes/.config/nvim/coc-settings.json".source = ./coc-settings.json; + home.file."/home/vylpes/.config/nvim/lua/plugins.lua".source = ./lua/plugins.lua; } diff --git a/config/packages/neovim/init.lua b/config/packages/neovim/init.lua index 0ca4f94..06cbfd7 100644 --- a/config/packages/neovim/init.lua +++ b/config/packages/neovim/init.lua @@ -1,3 +1,5 @@ +lua require("plugins") + -- Leader key vim.g.mapleader = " " @@ -50,32 +52,6 @@ vim.opt.ttyfast = true -- Do not add a newline at the end of the file vim.opt.fixeol = false -vim.cmd [[packadd packer.nvim]] - -return require('packer').startup(function(use) - -- Packer can manage itself - use 'wbthomason/packer.nvim' - - -- Plugins - use 'dracula/vim' - use 'ryanoasis/vim-devicons' - -- use 'SirVer/ultisnips' - use 'honza/vim-snippets' - use 'scrooloose/nerdtree' - use 'preservim/nerdcommenter' - use 'mhinz/vim-startify' - use {'neoclide/coc.nvim', branch = 'release'} - use 'nvim-lua/plenary.nvim' - use 'ThePrimeagen/harpoon' - use {'junegunn/fzf', run = function() vim.fn['fzf#install']() end} - use 'junegunn/fzf.vim' - use 'neovim/nvim-lspconfig' - use 'jose-elias-alvarez/null-ls.nvim' - use 'MunifTanjim/prettier.nvim' - use 'github/copilot.vim' - use {'CopilotC-Nvim/CopilotChat.nvim', branch = 'canary'} -end) - -- Copilot Chat local prompts = require('CopilotChat.prompts') local select = require('CopilotChat.select') diff --git a/config/packages/neovim/lua/plugins.lua b/config/packages/neovim/lua/plugins.lua new file mode 100644 index 0000000..6660012 --- /dev/null +++ b/config/packages/neovim/lua/plugins.lua @@ -0,0 +1,25 @@ +vim.cmd [[packadd packer.nvim]] + +return require('packer').startup(function(use) + -- Packer can manage itself + use 'wbthomason/packer.nvim' + + -- Plugins + use 'dracula/vim' + use 'ryanoasis/vim-devicons' + -- use 'SirVer/ultisnips' + use 'honza/vim-snippets' + use 'scrooloose/nerdtree' + use 'preservim/nerdcommenter' + use 'mhinz/vim-startify' + use {'neoclide/coc.nvim', branch = 'release'} + use 'nvim-lua/plenary.nvim' + use 'ThePrimeagen/harpoon' + use {'junegunn/fzf', run = function() vim.fn['fzf#install']() end} + use 'junegunn/fzf.vim' + use 'neovim/nvim-lspconfig' + use 'jose-elias-alvarez/null-ls.nvim' + use 'MunifTanjim/prettier.nvim' + use 'github/copilot.vim' + use {'CopilotC-Nvim/CopilotChat.nvim', branch = 'canary'} +end) From 026f2be3791231db3b70150e180c7d0078f0f77c Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Wed, 30 Oct 2024 12:16:21 +0000 Subject: [PATCH 12/16] Bootstrap packer --- config/packages/neovim/init.lua | 41 ++++++++++++++++++++++++-- config/packages/neovim/lua/plugins.lua | 25 ---------------- 2 files changed, 39 insertions(+), 27 deletions(-) delete mode 100644 config/packages/neovim/lua/plugins.lua diff --git a/config/packages/neovim/init.lua b/config/packages/neovim/init.lua index 06cbfd7..bf89820 100644 --- a/config/packages/neovim/init.lua +++ b/config/packages/neovim/init.lua @@ -1,5 +1,3 @@ -lua require("plugins") - -- Leader key vim.g.mapleader = " " @@ -205,3 +203,42 @@ vim.api.nvim_set_keymap('v', 'pf', ':CopilotChatFix', { noremap = tr vim.api.nvim_set_keymap('v', 'po', ':CopilotChatOptimize', { noremap = true, silent = true }) vim.api.nvim_set_keymap('v', 'pd', ':CopilotChatDocs', { noremap = true, silent = true }) vim.api.nvim_set_keymap('v', 'pt', ':CopilotChatTests', { noremap = true, silent = true }) + +local ensure_packer = function() + local fn = vim.fn + local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim' + if fn.empty(fn.glob(install_path)) > 0 then + fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path}) + vim.cmd [[packadd packer.nvim]] + return true + end + return false +end + +local packer_bootstrap = ensure_packer() + +vim.cmd [[packadd packer.nvim]] + +return require('packer').startup(function(use) + -- Packer can manage itself + use 'wbthomason/packer.nvim' + + -- Plugins + use 'dracula/vim' + use 'ryanoasis/vim-devicons' + -- use 'SirVer/ultisnips' + use 'honza/vim-snippets' + use 'scrooloose/nerdtree' + use 'preservim/nerdcommenter' + use 'mhinz/vim-startify' + use {'neoclide/coc.nvim', branch = 'release'} + use 'nvim-lua/plenary.nvim' + use 'ThePrimeagen/harpoon' + use {'junegunn/fzf', run = function() vim.fn['fzf#install']() end} + use 'junegunn/fzf.vim' + use 'neovim/nvim-lspconfig' + use 'jose-elias-alvarez/null-ls.nvim' + use 'MunifTanjim/prettier.nvim' + use 'github/copilot.vim' + use {'CopilotC-Nvim/CopilotChat.nvim', branch = 'canary'} +end) diff --git a/config/packages/neovim/lua/plugins.lua b/config/packages/neovim/lua/plugins.lua deleted file mode 100644 index 6660012..0000000 --- a/config/packages/neovim/lua/plugins.lua +++ /dev/null @@ -1,25 +0,0 @@ -vim.cmd [[packadd packer.nvim]] - -return require('packer').startup(function(use) - -- Packer can manage itself - use 'wbthomason/packer.nvim' - - -- Plugins - use 'dracula/vim' - use 'ryanoasis/vim-devicons' - -- use 'SirVer/ultisnips' - use 'honza/vim-snippets' - use 'scrooloose/nerdtree' - use 'preservim/nerdcommenter' - use 'mhinz/vim-startify' - use {'neoclide/coc.nvim', branch = 'release'} - use 'nvim-lua/plenary.nvim' - use 'ThePrimeagen/harpoon' - use {'junegunn/fzf', run = function() vim.fn['fzf#install']() end} - use 'junegunn/fzf.vim' - use 'neovim/nvim-lspconfig' - use 'jose-elias-alvarez/null-ls.nvim' - use 'MunifTanjim/prettier.nvim' - use 'github/copilot.vim' - use {'CopilotC-Nvim/CopilotChat.nvim', branch = 'canary'} -end) From 9f8fce9599ca5fc0a6abc614c3d75729f1e7cf0e Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Wed, 30 Oct 2024 12:16:49 +0000 Subject: [PATCH 13/16] Remove plugins.lua --- config/packages/neovim/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/config/packages/neovim/default.nix b/config/packages/neovim/default.nix index 4eb8d90..dc0b484 100644 --- a/config/packages/neovim/default.nix +++ b/config/packages/neovim/default.nix @@ -1,5 +1,4 @@ { home.file."/home/vylpes/.config/nvim/init.lua".source = ./init.lua; home.file."/home/vylpes/.config/nvim/coc-settings.json".source = ./coc-settings.json; - home.file."/home/vylpes/.config/nvim/lua/plugins.lua".source = ./lua/plugins.lua; } From 50541208e65b08a1d7656fd08dab5ab5bbadd6e7 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Wed, 30 Oct 2024 12:17:54 +0000 Subject: [PATCH 14/16] Move copilot chat --- config/packages/neovim/init.lua | 42 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/config/packages/neovim/init.lua b/config/packages/neovim/init.lua index bf89820..3efa67b 100644 --- a/config/packages/neovim/init.lua +++ b/config/packages/neovim/init.lua @@ -50,27 +50,6 @@ vim.opt.ttyfast = true -- Do not add a newline at the end of the file vim.opt.fixeol = false --- Copilot Chat -local prompts = require('CopilotChat.prompts') -local select = require('CopilotChat.select') - -require("CopilotChat").setup { - debug = false, - - question_header = '## User ', - answer_header = '## Copilot ', - error_header = '## Error ', - separator = '---', - - selection = function(source) - return select.visual(source) or select.line(source) - end, - - window = { - layout = 'float', - }, -} - if vim.fn.has("termguicolors") == 1 then vim.opt.termguicolors = true end @@ -242,3 +221,24 @@ return require('packer').startup(function(use) use 'github/copilot.vim' use {'CopilotC-Nvim/CopilotChat.nvim', branch = 'canary'} end) + +-- Copilot Chat +local prompts = require('CopilotChat.prompts') +local select = require('CopilotChat.select') + +require("CopilotChat").setup { + debug = false, + + question_header = '## User ', + answer_header = '## Copilot ', + error_header = '## Error ', + separator = '---', + + selection = function(source) + return select.visual(source) or select.line(source) + end, + + window = { + layout = 'float', + }, +} From bb44f0de331fb281f77ccb4de3848f4372d36671 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Wed, 30 Oct 2024 12:18:43 +0000 Subject: [PATCH 15/16] Remove return --- config/packages/neovim/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/packages/neovim/init.lua b/config/packages/neovim/init.lua index 3efa67b..b589ae8 100644 --- a/config/packages/neovim/init.lua +++ b/config/packages/neovim/init.lua @@ -198,7 +198,7 @@ local packer_bootstrap = ensure_packer() vim.cmd [[packadd packer.nvim]] -return require('packer').startup(function(use) +require('packer').startup(function(use) -- Packer can manage itself use 'wbthomason/packer.nvim' From da5cdc5220107de11bf68cd838446830a6f90afb Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Wed, 30 Oct 2024 12:19:56 +0000 Subject: [PATCH 16/16] Termgui colours --- config/packages/neovim/init.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/config/packages/neovim/init.lua b/config/packages/neovim/init.lua index b589ae8..cfbb39d 100644 --- a/config/packages/neovim/init.lua +++ b/config/packages/neovim/init.lua @@ -50,10 +50,6 @@ vim.opt.ttyfast = true -- Do not add a newline at the end of the file vim.opt.fixeol = false -if vim.fn.has("termguicolors") == 1 then - vim.opt.termguicolors = true -end - -- Enable syntax highlighting vim.cmd("syntax enable") @@ -242,3 +238,8 @@ require("CopilotChat").setup { layout = 'float', }, } + +if vim.fn.has("termguicolors") == 1 then + vim.opt.termguicolors = true +end +