From c3574de9bc369d82c4cbea3e4639169d6e859e0e Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 14 Apr 2025 15:20:54 +0100 Subject: [PATCH] First day of development changes --- lua/autocmd.lua | 20 ++-- lua/keymap.lua | 12 +-- lua/plugins/codecompanion.lua | 21 +++- lua/plugins/copilot.lua | 2 +- lua/plugins/lint.lua | 3 + lua/plugins/lsp.lua | 29 +++++ lua/plugins/oil.lua | 4 + lua/plugins/telescope.lua | 198 ++++++++++++++++++---------------- 8 files changed, 177 insertions(+), 112 deletions(-) diff --git a/lua/autocmd.lua b/lua/autocmd.lua index 43710ec..8c3fc75 100644 --- a/lua/autocmd.lua +++ b/lua/autocmd.lua @@ -20,17 +20,17 @@ vim.api.nvim_create_autocmd('FocusLost', { command = 'silent! wa', -- Save all files when moving away from the window }) -vim.api.nvim_create_autocmd('InsertLeave', { - group = autosave_group, - pattern = '*', - command = 'silent! wa', -- Save all files when leaving insert mode -}) +-- vim.api.nvim_create_autocmd('InsertLeave', { +-- group = autosave_group, +-- pattern = '*', +-- command = 'silent! wa', -- Save all files when leaving insert mode +-- }) -vim.api.nvim_create_autocmd('TextChanged', { - group = autosave_group, - pattern = '*', - command = 'silent! wa', -- Save all files when text is changed -}) +-- vim.api.nvim_create_autocmd('TextChanged', { +-- group = autosave_group, +-- pattern = '*', +-- command = 'silent! wa', -- Save all files when text is changed +-- }) vim.api.nvim_create_autocmd("User", { pattern = "OilActionsPost", diff --git a/lua/keymap.lua b/lua/keymap.lua index eab1f20..5138f98 100644 --- a/lua/keymap.lua +++ b/lua/keymap.lua @@ -40,13 +40,11 @@ vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', 'Telescope lsp_document_sym vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', 'Telescope lsp_workspace_symbols', { desc = 'Show symbols in workspace' }) vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', 'Telescope oldfiles', { desc = 'Show recently opened files' }) vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', function() - require('telescope.builtin').find_files { - show_untracked = true, - hidden = true, - } -end, { desc = 'Find version controlled files' }) + require('telescope.builtin').git_files() +end, { desc = 'Find all files' }) vim.keymap.set({ 'n', 'v', 'c', 'i' }, '', function() require('telescope.builtin').find_files { + show_untracked = true, no_ignore = true, hidden = true, } @@ -87,15 +85,15 @@ vim.keymap.set('n', 'gaf', 'Git add %', { desc = 'Git add curre vim.keymap.set('n', 'gaa', 'Git add --all', { desc = 'Git add all unstaged changes' }) vim.keymap.set('n', 'gap', 'Git add --patch --all', { desc = 'Git add all unstaged changes interactively' }) vim.keymap.set('n', 'gb', 'Git blame', { desc = 'Git blame' }) -vim.keymap.set('n', 'gcm', 'Git commit', { desc = 'Git commit' }) +vim.keymap.set('n', 'gcm', 'Git commit -v', { desc = 'Git commit' }) vim.keymap.set('n', 'gp', 'Git push', { desc = 'Git push' }) vim.keymap.set('n', 'gup', 'Git pull --rebase', { desc = 'Git pull --rebase' }) vim.keymap.set('n', 'gsb', 'Git status', { desc = 'Git status' }) vim.keymap.set('n', 'gd', 'Git diff', { desc = 'Git diff' }) +vim.keymap.set('n', 'gdc', 'Git diff --cached', { desc = 'Git diff' }) vim.keymap.set('n', 'gl', 'Git log', { desc = 'Git log' }) vim.keymap.set('n', 'gun', 'Git reset -- %', { desc = 'Git unstage file' }) vim.keymap.set('n', 'gco', 'Git checkout', { desc = 'Git checkout' }) -vim.keymap.set('n', 'gc', 'Git commit', { desc = 'Git commit' }) vim.keymap.set('n', 'G', 'Git', { desc = 'Git' }) vim.keymap.set('n', 'gsta', 'Git stash push', { desc = 'Git stash' }) vim.keymap.set('n', 'gstA', 'Git stash apply', { desc = 'Git stash apply' }) diff --git a/lua/plugins/codecompanion.lua b/lua/plugins/codecompanion.lua index f2df9c9..50a7595 100644 --- a/lua/plugins/codecompanion.lua +++ b/lua/plugins/codecompanion.lua @@ -1,8 +1,25 @@ -require('helpers').edit_cf('pa', '/lua/plugins/avante.lua') +require('helpers').edit_cf('pa', '/lua/plugins/codecompanion.lua') return { 'olimorris/codecompanion.nvim', - opts = {}, + opts = { + adapters = { + copilot = function() + return require('codecompanion.adapters').extend('copilot', { + schema = { + model = { + default = 'claude-3.7-sonnet', + }, + }, + }) + end, + }, + display = { + chat = { + show_settings = true, + }, + }, + }, dependencies = { 'nvim-lua/plenary.nvim', 'nvim-treesitter/nvim-treesitter', diff --git a/lua/plugins/copilot.lua b/lua/plugins/copilot.lua index 496abd0..8e490ed 100644 --- a/lua/plugins/copilot.lua +++ b/lua/plugins/copilot.lua @@ -1,3 +1,3 @@ return { - 'zbirenbaum/copilot.lua', + 'github/copilot.vim', } diff --git a/lua/plugins/lint.lua b/lua/plugins/lint.lua index 65d13a0..153466c 100644 --- a/lua/plugins/lint.lua +++ b/lua/plugins/lint.lua @@ -7,6 +7,9 @@ return { lint.linters_by_ft = { markdown = { 'markdownlint' }, } + lint.linters_by_ft['javascript'] = nil + lint.linters_by_ft['vue'] = nil + lint.linters_by_ft['html'] = nil -- To allow other plugins to add linters to require('lint').linters_by_ft, -- instead set linters_by_ft like this: diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 1d95386..129c5ae 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,4 +1,6 @@ -- Main LSP Configuration +require('helpers').edit_cf('pl', '/lua/plugins/lsp.lua') + return { 'neovim/nvim-lspconfig', dependencies = { @@ -194,6 +196,9 @@ return { -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. -- - settings (table): Override the default settings passed when initializing the server. -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ + + local mason_registry = require 'mason-registry' + local vue_language_server_path = mason_registry.get_package('vue-language-server'):get_install_path() .. '/node_modules/@vue/language-server' local servers = { -- clangd = {}, -- gopls = {}, @@ -222,6 +227,30 @@ return { }, }, }, + ts_ls = { + init_options = { + plugins = { + { + name = '@vue/typescript-plugin', + location = vue_language_server_path, + languages = { 'vue' }, + }, + }, + }, + filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }, + }, + + volar = { + on_attach = function(client, bufnr) + client.server_capabilities.documentFormattingProvider = false + end, + }, + + phpactor = { + on_attach = function(client, bufnr) + client.server_capabilities.documentFormattingProvider = false + end, + }, } -- Ensure the servers and tools above are installed diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua index b77a1ab..e82e9b3 100644 --- a/lua/plugins/oil.lua +++ b/lua/plugins/oil.lua @@ -1,4 +1,5 @@ -- Filesystem manager +require('helpers').edit_cf('po', '/lua/plugins/oil.lua') vim.keymap.set('n', '-', 'Oil', { desc = 'Open parent directory' }) @@ -10,6 +11,9 @@ return { view_options = { show_hidden = true, }, + keymaps = { + [''] = false, + }, }, -- Optional dependencies dependencies = { { 'echasnovski/mini.icons', opts = {} } }, diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index b34e578..de1834b 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,105 +1,119 @@ -- Fuzzy Finder (files, lsp, etc) -- See :help telescope return { - "nvim-telescope/telescope.nvim", - event = "VimEnter", - dependencies = { - "nvim-lua/plenary.nvim", - { -- If encountering errors, see telescope-fzf-native README for installation instructions - "nvim-telescope/telescope-fzf-native.nvim", + 'nvim-telescope/telescope.nvim', + event = 'VimEnter', + dependencies = { + 'nvim-lua/plenary.nvim', + { -- If encountering errors, see telescope-fzf-native README for installation instructions + 'nvim-telescope/telescope-fzf-native.nvim', - -- `build` is used to run some command when the plugin is installed/updated. - -- This is only run then, not every time Neovim starts up. - build = "make", + -- `build` is used to run some command when the plugin is installed/updated. + -- This is only run then, not every time Neovim starts up. + build = 'make', - -- `cond` is a condition used to determine whether this plugin should be - -- installed and loaded. - cond = function() - return vim.fn.executable("make") == 1 - end, - }, - { "nvim-telescope/telescope-ui-select.nvim" }, + -- `cond` is a condition used to determine whether this plugin should be + -- installed and loaded. + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + { 'nvim-telescope/telescope-ui-select.nvim' }, - -- Useful for getting pretty icons, but requires a Nerd Font. - { "nvim-tree/nvim-web-devicons", enabled = vim.g.have_nerd_font }, - }, - config = function() - -- Telescope is a fuzzy finder that comes with a lot of different things that - -- it can fuzzy find! It's more than just a "file finder", it can search - -- many different aspects of Neovim, your workspace, LSP, and more! - -- - -- The easiest way to use Telescope, is to start by doing something like: - -- :Telescope help_tags - -- - -- After running this command, a window will open up and you're able to - -- type in the prompt window. You'll see a list of `help_tags` options and - -- a corresponding preview of the help. - -- - -- Two important keymaps to use while in Telescope are: - -- - Insert mode: - -- - Normal mode: ? - -- - -- This opens a window that shows you all of the keymaps for the current - -- Telescope picker. This is really useful to discover what Telescope can - -- do as well as how to actually do it! + -- Useful for getting pretty icons, but requires a Nerd Font. + { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + }, + config = function() + -- Telescope is a fuzzy finder that comes with a lot of different things that + -- it can fuzzy find! It's more than just a "file finder", it can search + -- many different aspects of Neovim, your workspace, LSP, and more! + -- + -- The easiest way to use Telescope, is to start by doing something like: + -- :Telescope help_tags + -- + -- After running this command, a window will open up and you're able to + -- type in the prompt window. You'll see a list of `help_tags` options and + -- a corresponding preview of the help. + -- + -- Two important keymaps to use while in Telescope are: + -- - Insert mode: + -- - Normal mode: ? + -- + -- This opens a window that shows you all of the keymaps for the current + -- Telescope picker. This is really useful to discover what Telescope can + -- do as well as how to actually do it! - -- [[ Configure Telescope ]] - -- See `:help telescope` and `:help telescope.setup()` - require("telescope").setup({ - -- You can put your default mappings / updates / etc. in here - -- All the info you're looking for is in `:help telescope.setup()` - -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, - -- pickers = {} - extensions = { - ["ui-select"] = { - require("telescope.themes").get_dropdown(), - }, - }, - }) + -- [[ Configure Telescope ]] + -- See `:help telescope` and `:help telescope.setup()` + require('telescope').setup { + -- You can put your default mappings / updates / etc. in here + -- All the info you're looking for is in `:help telescope.setup()` + -- + -- defaults = { + -- mappings = { + -- i = { [''] = 'to_fuzzy_refine' }, + -- }, + -- }, + -- pickers = {} + extensions = { + ['ui-select'] = { + require('telescope.themes').get_dropdown(), + }, + }, + defaults = { + mappings = { + i = { + -- Insert mode mappings for Telescope + [''] = 'move_selection_next', + [''] = 'move_selection_previous', + }, + n = { + -- Normal mode mappings for Telescope + [''] = 'move_selection_next', + [''] = 'move_selection_previous', + }, + }, + }, + } - -- Enable Telescope extensions if they are installed - pcall(require("telescope").load_extension, "fzf") - pcall(require("telescope").load_extension, "ui-select") + -- Enable Telescope extensions if they are installed + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') - -- See `:help telescope.builtin` - local builtin = require("telescope.builtin") - vim.keymap.set("n", "sh", builtin.help_tags, { desc = "[S]earch [H]elp" }) - vim.keymap.set("n", "sk", builtin.keymaps, { desc = "[S]earch [K]eymaps" }) - vim.keymap.set("n", "sf", builtin.find_files, { desc = "[S]earch [F]iles" }) - vim.keymap.set("n", "ss", builtin.builtin, { desc = "[S]earch [S]elect Telescope" }) - vim.keymap.set("n", "sw", builtin.grep_string, { desc = "[S]earch current [W]ord" }) - vim.keymap.set("n", "sg", builtin.live_grep, { desc = "[S]earch by [G]rep" }) - vim.keymap.set("n", "sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" }) - vim.keymap.set("n", "sr", builtin.resume, { desc = "[S]earch [R]esume" }) - vim.keymap.set("n", "s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) - vim.keymap.set("n", "", builtin.buffers, { desc = "[ ] Find existing buffers" }) + -- See `:help telescope.builtin` + local builtin = require 'telescope.builtin' + vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) - -- Slightly advanced example of overriding default behavior and theme - vim.keymap.set("n", "/", function() - -- You can pass additional configuration to Telescope to change the theme, layout, etc. - builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ - winblend = 10, - previewer = false, - })) - end, { desc = "[/] Fuzzily search in current buffer" }) + -- Slightly advanced example of overriding default behavior and theme + vim.keymap.set('n', '/', function() + -- You can pass additional configuration to Telescope to change the theme, layout, etc. + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) - -- It's also possible to pass additional configuration options. - -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set("n", "s/", function() - builtin.live_grep({ - grep_open_files = true, - prompt_title = "Live Grep in Open Files", - }) - end, { desc = "[S]earch [/] in Open Files" }) + -- It's also possible to pass additional configuration options. + -- See `:help telescope.builtin.live_grep()` for information about particular keys + vim.keymap.set('n', 's/', function() + builtin.live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } + end, { desc = '[S]earch [/] in Open Files' }) - -- Shortcut for searching your Neovim configuration files - vim.keymap.set("n", "sn", function() - builtin.find_files({ cwd = vim.fn.stdpath("config") }) - end, { desc = "[S]earch [N]eovim files" }) - end, + -- Shortcut for searching your Neovim configuration files + vim.keymap.set('n', 'sn', function() + builtin.find_files { cwd = vim.fn.stdpath 'config' } + end, { desc = '[S]earch [N]eovim files' }) + end, }