From 278736ec4eef5cfe2759a55d3c8a1da68353eec1 Mon Sep 17 00:00:00 2001 From: Michaël Ball Date: Thu, 5 Dec 2024 16:11:40 +0000 Subject: Updates for gen.nvim --- neovim/.config/nvim/lua/plugins/gen_nvim.lua | 26 +++++++-------- neovim/.config/nvim/lua/settings.lua | 47 ++++++++++++++++++---------- 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/neovim/.config/nvim/lua/plugins/gen_nvim.lua b/neovim/.config/nvim/lua/plugins/gen_nvim.lua index 074f863..52dd67d 100644 --- a/neovim/.config/nvim/lua/plugins/gen_nvim.lua +++ b/neovim/.config/nvim/lua/plugins/gen_nvim.lua @@ -3,18 +3,18 @@ return { "David-Kunz/gen.nvim", cmd = "Gen", opts = { - model = "llama3.2:3b-instruct-fp16", -- The default model to use. - quit_map = "q", -- set keymap to close the response window - retry_map = "", -- set keymap to re-send the current prompt - accept_map = "", -- set keymap to replace the previous selection with the last result - host = "localhost", -- The host running the Ollama service. - port = "11434", -- The port on which the Ollama service is listening. - display_mode = "split", -- The display mode. Can be "float" or "split" or "horizontal-split". - show_prompt = false, -- Shows the prompt submitted to Ollama. - show_model = true, -- Displays which model you are using at the beginning of your chat session. - no_auto_close = false, -- Never closes the window automatically. - file = false, -- Write the payload to a temporary file to keep the command short. - hidden = false, -- Hide the generation window (if true, will implicitly set `prompt.replace = true`), requires Neovim >= 0.10 + model = "llama3.2:3b-instruct-fp16", -- The default model to use. + quit_map = "q", -- set keymap to close the response window + retry_map = "", -- set keymap to re-send the current prompt + accept_map = "", -- set keymap to replace the previous selection with the last result + host = "localhost", -- The host running the Ollama service. + port = "11434", -- The port on which the Ollama service is listening. + display_mode = "split", -- The display mode. Can be "float" or "split" or "horizontal-split". + show_prompt = false, -- Shows the prompt submitted to Ollama. + show_model = true, -- Displays which model you are using at the beginning of your chat session. + no_auto_close = false, -- Never closes the window automatically. + file = false, -- Write the payload to a temporary file to keep the command short. + hidden = false, -- Hide the generation window (if true, will implicitly set `prompt.replace = true`), requires Neovim >= 0.10 init = function(options) pcall(io.popen, "ollama serve > /dev/null 2>&1 &") end, -- Function to initialize Ollama command = function(options) @@ -26,7 +26,7 @@ return { -- The executed command must return a JSON object with { response, context } -- (context property is optional). -- list_models = '', -- Retrieves a list of model names - debug = false -- Prints errors and the command which is run. + debug = false -- Prints errors and the command which is run. }, }, } diff --git a/neovim/.config/nvim/lua/settings.lua b/neovim/.config/nvim/lua/settings.lua index ad8aaff..6daf849 100644 --- a/neovim/.config/nvim/lua/settings.lua +++ b/neovim/.config/nvim/lua/settings.lua @@ -25,7 +25,7 @@ vim.opt.linebreak = true vim.opt.showbreak = '↪ ' vim.opt.breakindent = true vim.opt.termguicolors = true -vim.cmd[[ +vim.cmd [[ syntax on filetype on filetype plugin on @@ -44,24 +44,24 @@ if vim.g.neovide then end if vim.g.neovide then - vim.keymap.set('n', '', ':w') -- Save - vim.keymap.set('v', '', '"+y') -- Copy - vim.keymap.set('n', '', '"+P') -- Paste normal mode - vim.keymap.set('v', '', '"+P') -- Paste visual mode - vim.keymap.set('c', '', '+') -- Paste command mode + vim.keymap.set('n', '', ':w') -- Save + vim.keymap.set('v', '', '"+y') -- Copy + vim.keymap.set('n', '', '"+P') -- Paste normal mode + vim.keymap.set('v', '', '"+P') -- Paste visual mode + vim.keymap.set('c', '', '+') -- Paste command mode vim.keymap.set('i', '', 'l"+Pli') -- Paste insert mode end -- Allow clipboard copy paste in neovim -vim.api.nvim_set_keymap('', '', '+p', { noremap = true, silent = true}) -vim.api.nvim_set_keymap('!', '', '+', { noremap = true, silent = true}) -vim.api.nvim_set_keymap('t', '', '+', { noremap = true, silent = true}) -vim.api.nvim_set_keymap('v', '', '+', { noremap = true, silent = true}) +vim.api.nvim_set_keymap('', '', '+p', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('!', '', '+', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('t', '', '+', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('v', '', '+', { noremap = true, silent = true }) -- Autocommands local indent_rules_augroup = vim.api.nvim_create_augroup('Indents', {}) -vim.api.nvim_create_autocmd( { 'FileType' }, { +vim.api.nvim_create_autocmd({ 'FileType' }, { pattern = { 'make', 'sh', 'zsh' }, group = indent_rules_augroup, callback = function() @@ -71,7 +71,7 @@ vim.api.nvim_create_autocmd( { 'FileType' }, { vim.opt_local.expandtab = false end }) -vim.api.nvim_create_autocmd( { 'FileType' }, { +vim.api.nvim_create_autocmd({ 'FileType' }, { pattern = { 'go' }, group = indent_rules_augroup, callback = function() @@ -81,7 +81,7 @@ vim.api.nvim_create_autocmd( { 'FileType' }, { vim.opt_local.expandtab = false end }) -vim.api.nvim_create_autocmd( { 'FileType' }, { +vim.api.nvim_create_autocmd({ 'FileType' }, { pattern = { 'javascript', 'lua' }, group = indent_rules_augroup, callback = function() @@ -92,7 +92,7 @@ vim.api.nvim_create_autocmd( { 'FileType' }, { }) local wrap_rules_augroup = vim.api.nvim_create_augroup('Wrap', {}) -vim.api.nvim_create_autocmd( { 'FileType' }, { +vim.api.nvim_create_autocmd({ 'FileType' }, { pattern = { 'markdown', 'rst', 'text' }, group = wrap_rules_augroup, callback = function() @@ -101,7 +101,7 @@ vim.api.nvim_create_autocmd( { 'FileType' }, { }) local terminal_rules_augroup = vim.api.nvim_create_augroup('Terminal', {}) -vim.api.nvim_create_autocmd( { 'TermOpen' }, { +vim.api.nvim_create_autocmd({ 'TermOpen' }, { pattern = { '*' }, group = terminal_rules_augroup, callback = function() @@ -117,7 +117,7 @@ vim.api.nvim_create_autocmd( { 'TermOpen' }, { }) -- Terminal -vim.cmd[[ +vim.cmd [[ tnoremap tnoremap h tnoremap j @@ -174,3 +174,18 @@ end vim.diagnostic.config({ underline = { severity = vim.diagnostic.severity.ERROR }, }) + +-- Disable diagnostics for gen.nvim +local lsp_grp = vim.api.nvim_create_augroup("lsp_disable", { clear = true }) +vim.api.nvim_create_autocmd({ "LspAttach" }, { + group = lsp_grp, + callback = function(args) + if vim.bo.buftype == "nofile" then + local bufnr = args.buf + vim.diagnostic.enable(false, { bufnr = bufnr }) + for _, client in ipairs(vim.lsp.get_clients({ bufnr = bufnr })) do + vim.lsp.buf_detach_client(bufnr, client.id) + end + end + end +}) -- cgit v1.2.3