From 9248cf468be776e9020f383fdb543584e141f2e5 Mon Sep 17 00:00:00 2001 From: ray Date: Fri, 19 Dec 2025 20:16:21 +0000 Subject: [PATCH] add borders around completion popups --- lua/autocmds.lua | 135 ++++++++++++++++++++++---------------------- lua/plugins/cmp.lua | 79 +++++++++++++------------- lua/settings.lua | 79 +++++++++++++------------- 3 files changed, 149 insertions(+), 144 deletions(-) diff --git a/lua/autocmds.lua b/lua/autocmds.lua index 22a7129..240d169 100644 --- a/lua/autocmds.lua +++ b/lua/autocmds.lua @@ -1,102 +1,101 @@ -- Non-plugin autocommands (minimal placeholder for bootstrap) -local aug = vim.api.nvim_create_augroup('UserDefaults', { clear = true }) +local aug = vim.api.nvim_create_augroup("UserDefaults", { clear = true }) -- Phase 10.3: Templates (auto-populate new files from templates) -local template_aug = vim.api.nvim_create_augroup('Templates', { clear = true }) +local template_aug = vim.api.nvim_create_augroup("Templates", { clear = true }) vim.api.nvim_create_autocmd("BufNewFile", { - group = template_aug, - pattern = "*.sh", - callback = function() - -- Read template at top of file, then move to end - vim.cmd('0read ~/.config/nvim/templates/template.sh') - vim.cmd('normal! G') - end, + group = template_aug, + pattern = "*.sh", + callback = function() + -- Read template at top of file, then move to end + vim.cmd("0read ~/.config/nvim/templates/template.sh") + vim.cmd("normal! G") + end, }) -- Phase 9.4: Per-filetype indentation settings to match formatters -- PHP: WordPress coding standards (tabs, displayed as 2 spaces) vim.api.nvim_create_autocmd("FileType", { - group = aug, - pattern = "php", - callback = function() - vim.opt_local.expandtab = false -- Use actual tabs (WordPress standard) - vim.opt_local.tabstop = 2 -- Display tabs as 2 spaces wide - vim.opt_local.shiftwidth = 2 -- Indent/outdent by 2 columns (one tab) - vim.opt_local.softtabstop = 2 -- Tab key inserts 2 columns (one tab) - end, + group = aug, + pattern = "php", + callback = function() + vim.opt_local.expandtab = false -- Use actual tabs (WordPress standard) + vim.opt_local.tabstop = 2 -- Display tabs as 2 spaces wide + vim.opt_local.shiftwidth = 2 -- Indent/outdent by 2 columns (one tab) + vim.opt_local.softtabstop = 2 -- Tab key inserts 2 columns (one tab) + end, }) -- JavaScript, TypeScript, JSON, CSS: Prettier defaults (2 spaces) vim.api.nvim_create_autocmd("FileType", { - group = aug, - pattern = { "javascript", "javascriptreact", "typescript", "typescriptreact", "json", "css", "scss", "html" }, - callback = function() - vim.opt_local.expandtab = true -- Use spaces (Prettier default) - vim.opt_local.tabstop = 2 -- Display as 2 spaces - vim.opt_local.shiftwidth = 2 -- Indent by 2 - vim.opt_local.softtabstop = 2 - end, + group = aug, + pattern = { "javascript", "javascriptreact", "typescript", "typescriptreact", "json", "css", "scss", "html" }, + callback = function() + vim.opt_local.expandtab = true -- Use spaces (Prettier default) + vim.opt_local.tabstop = 2 -- Display as 2 spaces + vim.opt_local.shiftwidth = 2 -- Indent by 2 + vim.opt_local.softtabstop = 2 + end, }) -- Lua: stylua defaults (2 spaces) vim.api.nvim_create_autocmd("FileType", { - group = aug, - pattern = "lua", - callback = function() - vim.opt_local.expandtab = true -- Use spaces (common for Lua configs) - vim.opt_local.tabstop = 2 -- Display as 2 spaces - vim.opt_local.shiftwidth = 2 -- Indent by 2 - vim.opt_local.softtabstop = 2 - end, + group = aug, + pattern = "lua", + callback = function() + vim.opt_local.expandtab = true -- Use spaces (common for Lua configs) + vim.opt_local.tabstop = 2 -- Display as 2 spaces + vim.opt_local.shiftwidth = 2 -- Indent by 2 + vim.opt_local.softtabstop = 2 + end, }) -- Markdown: Prettier defaults (2 spaces) vim.api.nvim_create_autocmd("FileType", { - group = aug, - pattern = "markdown", - callback = function() - vim.opt_local.expandtab = true -- Use spaces - vim.opt_local.tabstop = 2 -- Display as 2 spaces - vim.opt_local.shiftwidth = 2 -- Indent by 2 - vim.opt_local.softtabstop = 2 - end, + group = aug, + pattern = "markdown", + callback = function() + vim.opt_local.expandtab = true -- Use spaces + vim.opt_local.tabstop = 2 -- Display as 2 spaces + vim.opt_local.shiftwidth = 2 -- Indent by 2 + vim.opt_local.softtabstop = 2 + end, }) -- Python: Black defaults (4 spaces) vim.api.nvim_create_autocmd("FileType", { - group = aug, - pattern = "python", - callback = function() - vim.opt_local.expandtab = true -- Use spaces (PEP 8) - vim.opt_local.tabstop = 4 -- Display as 4 spaces - vim.opt_local.shiftwidth = 4 -- Indent by 4 - vim.opt_local.softtabstop = 4 - end, + group = aug, + pattern = "python", + callback = function() + vim.opt_local.expandtab = true -- Use spaces (PEP 8) + vim.opt_local.tabstop = 4 -- Display as 4 spaces + vim.opt_local.shiftwidth = 4 -- Indent by 4 + vim.opt_local.softtabstop = 4 + end, }) -- Phase 11.8: Colorize diagnostic severity in quickfix/location list vim.api.nvim_create_autocmd("FileType", { - group = aug, - pattern = "qf", -- Applies to both quickfix and location list - callback = function() - -- Use matchadd() for higher priority highlighting - -- This will override the default qf syntax - vim.fn.matchadd('qfError', '\\', 10) - vim.fn.matchadd('qfWarning', '\\', 10) - vim.fn.matchadd('qfInfo', '\\', 10) - vim.fn.matchadd('qfHint', '\\', 10) - vim.fn.matchadd('qfNote', '\\', 10) - - -- Also match uppercase variants - vim.fn.matchadd('qfError', '\\', 10) - vim.fn.matchadd('qfWarning', '\\', 10) - vim.fn.matchadd('qfInfo', '\\', 10) - vim.fn.matchadd('qfHint', '\\', 10) - vim.fn.matchadd('qfNote', '\\', 10) - end, + group = aug, + pattern = "qf", -- Applies to both quickfix and location list + callback = function() + -- Use matchadd() for higher priority highlighting + -- This will override the default qf syntax + vim.fn.matchadd("qfError", "\\", 10) + vim.fn.matchadd("qfWarning", "\\", 10) + vim.fn.matchadd("qfInfo", "\\", 10) + vim.fn.matchadd("qfHint", "\\", 10) + vim.fn.matchadd("qfNote", "\\", 10) + + -- Also match uppercase variants + vim.fn.matchadd("qfError", "\\", 10) + vim.fn.matchadd("qfWarning", "\\", 10) + vim.fn.matchadd("qfInfo", "\\", 10) + vim.fn.matchadd("qfHint", "\\", 10) + vim.fn.matchadd("qfNote", "\\", 10) + end, }) return {} - diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 3239f29..28094bb 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -1,41 +1,44 @@ return { - "hrsh7th/nvim-cmp", - event = "InsertEnter", - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "L3MON4D3/LuaSnip", - "zbirenbaum/copilot-cmp", -- Copilot completion source - }, - opts = function() - local cmp = require("cmp") - local luasnip = require("luasnip") + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "L3MON4D3/LuaSnip", + "zbirenbaum/copilot-cmp", -- Copilot completion source + }, + opts = function() + local cmp = require("cmp") + local luasnip = require("luasnip") - return { - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.confirm({ select = true }), -- Auto-select first item - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.abort(), - }), - sources = cmp.config.sources({ - { name = "copilot", group_index = 2 }, -- Copilot suggestions (priority 1) - { name = "nvim_lsp", group_index = 2 }, - { name = "path", group_index = 2 }, - { name = "buffer", group_index = 2 }, - }), - completion = { completeopt = "menu,menuone,noinsert" }, -- Auto-select first item - } - end, - config = function(_, opts) - require("cmp").setup(opts) - end, + return { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.confirm({ select = true }), -- Auto-select first item + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.abort(), + }), + sources = cmp.config.sources({ + { name = "copilot", group_index = 2 }, -- Copilot suggestions (priority 1) + { name = "nvim_lsp", group_index = 2 }, + { name = "path", group_index = 2 }, + { name = "buffer", group_index = 2 }, + }), + completion = { completeopt = "menu,menuone,noinsert" }, -- Auto-select first item + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + } + end, + config = function(_, opts) + require("cmp").setup(opts) + end, } - diff --git a/lua/settings.lua b/lua/settings.lua index a652b39..8b9eb77 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -6,64 +6,67 @@ vim.g.loaded_perl_provider = 0 vim.g.loaded_node_provider = 0 -- Enable project-local configuration files -vim.opt.exrc = true -- Load .nvim.lua from project root -vim.opt.secure = true -- Prompt before loading untrusted files +vim.opt.exrc = true -- Load .nvim.lua from project root +vim.opt.secure = true -- Prompt before loading untrusted files -- Phase 3.2: non-plugin settings (legacy values where specified) -- Completion UI for nvim-cmp -vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } +vim.opt.completeopt = { "menu", "menuone", "noselect" } -- Spelling -vim.opt.spelllang = { 'en_gb' } +vim.opt.spelllang = { "en_gb" } -- Keyword characters (add $ for PHP/shell variables, - for CSS/HTML/config files) -vim.opt.iskeyword:append('$') -vim.opt.iskeyword:append('-') +vim.opt.iskeyword:append("$") +vim.opt.iskeyword:append("-") -- Visuals -vim.opt.showbreak = ' ↳' +vim.opt.showbreak = " ↳" vim.opt.listchars = { - eol = '¬', - tab = '│ ', - trail = '~', - extends = '>', - precedes = '<', - space = '·', + eol = "¬", + tab = "│ ", + trail = "~", + extends = ">", + precedes = "<", + space = "·", } -- Enable line numbers and relative line numbers vim.opt.number = true vim.opt.relativenumber = true +-- Scrolloff settings +vim.opt.scrolloff = 4 + -- Phase 6.2: UX settings -vim.opt.signcolumn = 'yes' -- Always show sign column (for LSP diagnostics, git signs, etc.) -vim.opt.cursorline = true -- Highlight current line -vim.opt.colorcolumn = '80,120' -- Visual guides at 80 and 120 characters +vim.opt.signcolumn = "yes" -- Always show sign column (for LSP diagnostics, git signs, etc.) +vim.opt.cursorline = true -- Highlight current line +vim.opt.colorcolumn = "80,120" -- Visual guides at 80 and 120 characters -- Phase 9.4: Default indentation (per-filetype overrides in after/ftplugin/) -vim.opt.tabstop = 4 -- Display tabs as 4 spaces -vim.opt.shiftwidth = 4 -- Indent by 4 -vim.opt.softtabstop = 4 -- Backspace removes 4 spaces -vim.opt.expandtab = true -- Use spaces by default (overridden per-filetype) +vim.opt.tabstop = 4 -- Display tabs as 4 spaces +vim.opt.shiftwidth = 4 -- Indent by 4 +vim.opt.softtabstop = 4 -- Backspace removes 4 spaces +vim.opt.expandtab = true -- Use spaces by default (overridden per-filetype) -- LSP diagnostics configuration vim.diagnostic.config({ - virtual_text = { - spacing = 4, - prefix = '●', - -- Show severity (ERROR, WARN, INFO, HINT) - format = function(diagnostic) - return string.format("%s: %s", diagnostic.source or "", diagnostic.message) - end, - }, - signs = false, -- Disable signs (redundant with background highlights and virtual text) - underline = true, -- Use background highlights on problematic text - update_in_insert = false, -- Don't update diagnostics while typing - severity_sort = true, -- Sort by severity (errors first) - float = { - border = 'rounded', - source = 'always', -- Show diagnostic source - header = '', - prefix = '', - }, + virtual_text = { + spacing = 4, + prefix = "●", + -- Show severity (ERROR, WARN, INFO, HINT) + format = function(diagnostic) + return string.format("%s: %s", diagnostic.source or "", diagnostic.message) + end, + }, + signs = false, -- Disable signs (redundant with background highlights and virtual text) + underline = true, -- Use background highlights on problematic text + update_in_insert = false, -- Don't update diagnostics while typing + severity_sort = true, -- Sort by severity (errors first) + float = { + border = "rounded", + source = "always", -- Show diagnostic source + header = "", + prefix = "", + }, })