From 75a5dd8f9c4b6921b5281ed4a8518a0942cb99d1 Mon Sep 17 00:00:00 2001 From: inorishio Date: Thu, 5 Mar 2026 00:36:39 +0100 Subject: [PATCH] cmp works? ghost text works? --- autoload/neoformat/formatters/qml.vim | 13 ++ ftplugin/qml.lua | 8 +- lua/assets/icons.lua | 136 +++++++++---------- lua/config/ai/blink.lua | 177 ------------------------- lua/config/ai/chatgpt.lua | 38 ------ lua/config/ai/copilot.lua | 2 +- lua/config/ai/copilot_cmp.lua | 4 + lua/config/format/indent-blankline.lua | 32 ++--- lua/config/format/lspconfig.lua | 75 ++++++++++- lua/config/format/markdown.lua | 55 ++++++++ lua/config/format/neoformat.lua | 2 +- lua/config/snacks.lua | 2 +- lua/globals.lua | 9 +- lua/mappings.lua | 2 +- lua/options.lua | 1 - lua/plugins/formatter.lua | 12 ++ lua/plugins/init.lua | 10 +- 17 files changed, 262 insertions(+), 316 deletions(-) create mode 100644 autoload/neoformat/formatters/qml.vim delete mode 100644 lua/config/ai/blink.lua delete mode 100644 lua/config/ai/chatgpt.lua create mode 100644 lua/config/ai/copilot_cmp.lua create mode 100644 lua/config/format/markdown.lua create mode 100644 lua/plugins/formatter.lua diff --git a/autoload/neoformat/formatters/qml.vim b/autoload/neoformat/formatters/qml.vim new file mode 100644 index 0000000..4f09f0a --- /dev/null +++ b/autoload/neoformat/formatters/qml.vim @@ -0,0 +1,13 @@ +function! neoformat#formatters#qml#enabled() abort + return ['qmlformat'] +endfunction + +function! neoformat#formatters#qml#qmlformat() abort + return { + \ 'exe': '/usr/lib/qt6/bin/qmlformat', + \ 'args': ['-t', '-n', '--objects-spacing', '--functions-spacing', '-i'], + \ 'replace': 1, + \ 'stderr': 1, + \ 'stdin': 0 + \ } +endfunction diff --git a/ftplugin/qml.lua b/ftplugin/qml.lua index b645400..a70a496 100644 --- a/ftplugin/qml.lua +++ b/ftplugin/qml.lua @@ -1,12 +1,12 @@ local gen_hook = MiniSplitjoin.gen_hook -local curly = { brackets = { '%b{}' }, separator = ';' } -local curly_semi = { brackets = { '%b{}' }, separator = ';' } +local curly = { brackets = { "%b{}" }, separator = ";" } +local curly_semi = { brackets = { "%b{}" }, separator = ";" } local add_semicolon_curly = gen_hook.add_trailing_separator(curly) local remove_semicolon_curly = gen_hook.del_trailing_separator(curly) local pad_curly = gen_hook.pad_brackets(curly_semi) vim.b.minisplitjoin_config = { - split = { hooks_post = { remove_semicolon_curly }}, - join = { hooks_pre = { add_semicolon_curly }, hooks_post = { pad_curly }}, + split = { hooks_post = { remove_semicolon_curly } }, + join = { hooks_pre = { add_semicolon_curly }, hooks_post = { pad_curly } }, } diff --git a/lua/assets/icons.lua b/lua/assets/icons.lua index 15ffb90..ce7599b 100644 --- a/lua/assets/icons.lua +++ b/lua/assets/icons.lua @@ -1,74 +1,74 @@ local M = {} M.icons = { - misc = { - dots = "󰇘", - }, - ft = { - octo = " ", - gh = " ", - ["markdown.gh"] = " ", - }, - dap = { - Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" }, - Breakpoint = " ", - BreakpointCondition = " ", - BreakpointRejected = { " ", "DiagnosticError" }, - LogPoint = ".>", - }, - diagnostics = { - Error = " ", - Warn = " ", - Hint = " ", - Info = " ", - }, - git = { - added = " ", - modified = " ", - removed = " ", - }, - kinds = { - Array = " ", - Boolean = "󰨙 ", - Class = " ", - Codeium = "󰘦 ", - Color = " ", - Control = " ", - Collapsed = " ", - Constant = "󰏿 ", - Constructor = " ", - Copilot = " ", - Enum = " ", - EnumMember = " ", - Event = " ", - Field = " ", - File = " ", - Folder = " ", - Function = "󰊕 ", - Interface = " ", - Key = " ", - Keyword = " ", - Method = "󰊕 ", - Module = " ", - Namespace = "󰦮 ", - Null = " ", - Number = "󰎠 ", - Object = " ", - Operator = " ", - Package = " ", - Property = " ", - Reference = " ", - Snippet = "󱄽 ", - String = " ", - Struct = "󰆼 ", - Supermaven = " ", - TabNine = "󰏚 ", - Text = " ", - TypeParameter = " ", - Unit = " ", - Value = " ", - Variable = "󰀫 ", - }, + misc = { + dots = "󰇘", + }, + ft = { + octo = " ", + gh = " ", + ["markdown.gh"] = " ", + }, + dap = { + Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" }, + Breakpoint = " ", + BreakpointCondition = " ", + BreakpointRejected = { " ", "DiagnosticError" }, + LogPoint = ".>", + }, + diagnostics = { + Error = " ", + Warn = " ", + Hint = " ", + Info = " ", + }, + git = { + added = " ", + modified = " ", + removed = " ", + }, + kinds = { + Array = " ", + Boolean = "󰨙 ", + Class = " ", + Codeium = "󰘦 ", + Color = " ", + Control = " ", + Collapsed = " ", + Constant = "󰏿 ", + Constructor = " ", + Copilot = " ", + Enum = " ", + EnumMember = " ", + Event = " ", + Field = " ", + File = " ", + Folder = " ", + Function = "󰊕 ", + Interface = " ", + Key = " ", + Keyword = " ", + Method = "󰊕 ", + Module = " ", + Namespace = "󰦮 ", + Null = " ", + Number = "󰎠 ", + Object = " ", + Operator = " ", + Package = " ", + Property = " ", + Reference = " ", + Snippet = "󱄽 ", + String = " ", + Struct = "󰆼 ", + Supermaven = " ", + TabNine = "󰏚 ", + Text = " ", + TypeParameter = " ", + Unit = " ", + Value = " ", + Variable = "󰀫 ", + }, } return M diff --git a/lua/config/ai/blink.lua b/lua/config/ai/blink.lua deleted file mode 100644 index 4b2d066..0000000 --- a/lua/config/ai/blink.lua +++ /dev/null @@ -1,177 +0,0 @@ -local M = {} - -local icons = require("assets.icons").icons.kinds - -local devicons = { - default_icon = { icon = "󰈚", name = "Default" }, - js = { icon = "󰌞", name = "js" }, - ts = { icon = "󰛦", name = "ts" }, - lock = { icon = "󰌾", name = "lock" }, - ["robots.txt"] = { icon = "󰚩", name = "robots" }, -} - -M.components = { - kind_icon = { - text = function(ctx) - local icon = (icons[ctx.kind] or "󰈚") - - return icon .. " " - end, - }, - - kind = { - highlight = function(ctx) - return ctx.kind - end, - }, -} - -local opts = { - "saghen/blink.cmp", - dependencies = { - "rafamadriz/friendly-snippets", - { - "fang2hou/blink-copilot", - config = function() - require "config.blink-copilot" - end, - }, - }, - - version = "1.*", - - opts = { - keymap = { - [""] = { - function(cmp) - if cmp.is_visible() then - return cmp.select_next() - end - - if cmp.snippet_active() then - return cmp.snippet_forward() - end - end, - "fallback", - }, - [""] = { - function(cmp) - if cmp.is_visible() then - return cmp.select_prev() - end - - if cmp.snippet_active() then - return cmp.snippet_backward() - end - end, - "fallback", - }, - [""] = { "accept", "fallback" }, - ["Up"] = {}, - ["Down"] = {}, - }, - - appearance = { - nerd_font_variant = "mono", - }, - - cmdline = { - completion = { - menu = { auto_show = true }, - list = { selection = { preselect = false } }, - }, - - keymap = { - [""] = { - function(cmp) - if cmp.is_visible() then - return cmp.select_next() - end - end, - "fallback", - }, - [""] = { - function(cmp) - if cmp.is_visible() then - return cmp.select_prev() - end - end, - "fallback", - }, - [""] = { "accept", "fallback" }, - ["Up"] = {}, - ["Down"] = {}, - }, - }, - - completion = { - documentation = { auto_show = true, auto_show_delay_ms = 50 }, - keyword = { range = "full" }, - accept = { auto_brackets = { enabled = true } }, - ghost_text = { enabled = true }, - list = { - selection = { - -- preselect = false, - auto_insert = false, - }, - }, - - menu = { - scrollbar = false, - border = "single", - draw = { - padding = 1, - columns = { - { "kind_icon" }, - { "label", "label_description", gap = 1 }, - { "kind" }, - }, - components = M.components, - }, - }, - }, - - signature = { enabled = true }, - - sources = { - default = { "lsp", "path", "snippets", "buffer", "copilot" }, - providers = { - lsp = { - score_offset = 50, - }, - - path = { - opts = { - get_cwd = function() - return vim.fn.getcwd() - end, - }, - }, - - buffer = { - score_offset = -10, - }, - - snippets = { - score_offset = 0, - }, - - copilot = { - name = "copilot", - module = "blink-copilot", - score_offset = 100, - async = true, - }, - }, - }, - - snippets = { - preset = "default", - }, - - fuzzy = { implementation = "prefer_rust_with_warning" }, - }, - opts_extend = { "sources.default" }, -} - -return opts diff --git a/lua/config/ai/chatgpt.lua b/lua/config/ai/chatgpt.lua deleted file mode 100644 index 35a876c..0000000 --- a/lua/config/ai/chatgpt.lua +++ /dev/null @@ -1,38 +0,0 @@ -require("chatgpt").setup({ - api_host_cmd = "echo http://localhost:5000", - api_key_cmd = "echo ''", - openai_params = { - model = "Selene-1-Mini-Llama-3.1-8B-EXL3", - frequency_penalty = 0, - presence_penalty = 0, - max_tokens = 1024, - temperature = 0.1, - top_p = 1, - n = 1, - }, - keymaps = { - close = "", - close_n = "", - yank_last = "", - yank_last_code = "", - scroll_up = "", - scroll_down = "", - new_session = "", - cycle_windows = "", - cycle_modes = "", - next_message = "", - prev_message = "", - select_session = "", - rename_session = "r", - delete_session = "d", - draft_message = "", - edit_message = "e", - delete_message = "d", - toggle_settings = "", - toggle_sessions = "", - toggle_help = "", - toggle_message_role = "", - toggle_system_role_open = "", - stop_generating = "", - }, -}) diff --git a/lua/config/ai/copilot.lua b/lua/config/ai/copilot.lua index a730264..92850b2 100644 --- a/lua/config/ai/copilot.lua +++ b/lua/config/ai/copilot.lua @@ -17,7 +17,7 @@ require("copilot").setup({ suggestion = { enabled = true, auto_trigger = true, - hide_during_completion = true, + hide_during_completion = false, debounce = 75, keymap = { accept = "", diff --git a/lua/config/ai/copilot_cmp.lua b/lua/config/ai/copilot_cmp.lua new file mode 100644 index 0000000..a88bd06 --- /dev/null +++ b/lua/config/ai/copilot_cmp.lua @@ -0,0 +1,4 @@ +require("copilot_cmp").setup { + event = { "InsertEnter", "LspAttach" }, + fix_pairs = true, +} diff --git a/lua/config/format/indent-blankline.lua b/lua/config/format/indent-blankline.lua index f215551..1729f1e 100644 --- a/lua/config/format/indent-blankline.lua +++ b/lua/config/format/indent-blankline.lua @@ -1,29 +1,29 @@ local highlight = { - "RainbowRed", - "RainbowYellow", - "RainbowBlue", - "RainbowOrange", - "RainbowGreen", - "RainbowViolet", - "RainbowCyan", + "RainbowRed", + "RainbowYellow", + "RainbowBlue", + "RainbowOrange", + "RainbowGreen", + "RainbowViolet", + "RainbowCyan", } local hooks = require "ibl.hooks" -- create the highlight groups in the highlight setup hook, so they are reset -- every time the colorscheme changes hooks.register(hooks.type.HIGHLIGHT_SETUP, function() - vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" }) - vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" }) - vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" }) - vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" }) - vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" }) - vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" }) - vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" }) + vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" }) + vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" }) + vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" }) + vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" }) + vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" }) + vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" }) + vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" }) end) vim.g.rainbow_delimiters = { highlight = highlight } require("ibl").setup { - indent = { char = "▏" }, - scope = { highlight = highlight } + indent = { char = "▏" }, + scope = { highlight = highlight }, } hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark) diff --git a/lua/config/format/lspconfig.lua b/lua/config/format/lspconfig.lua index 17e941a..e9f2db3 100644 --- a/lua/config/format/lspconfig.lua +++ b/lua/config/format/lspconfig.lua @@ -1,3 +1,7 @@ +local cmp = require "cmp" +local cmp_lsp = require "cmp_nvim_lsp" +local cmp_kinds = require("assets.icons").icons.kinds + local function flatten_to_array(t) local res = {} local function _flatten(tbl) @@ -17,7 +21,7 @@ local capabilities = vim.tbl_deep_extend( "force", {}, vim.lsp.protocol.make_client_capabilities(), - require("blink.cmp").get_lsp_capabilities() + cmp_lsp.default_capabilities() ) require("fidget").setup {} @@ -95,6 +99,75 @@ require("mason-lspconfig").setup { }, } +cmp.setup { + preselect = "None", + formatting = { + fields = { "kind", "abbr" }, + format = function(entry, vim_item) + vim_item.kind = cmp_kinds[vim_item.kind] or "" + if entry.completion_item.detail then + vim_item.menu = entry.completion_item.detail + end + return vim_item + end, + }, + completion = { completeopt = "menu,menuone" }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + + view = { + entries = "custom", + }, + + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }, + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + require("luasnip").expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + require("luasnip").jump(-1) + else + fallback() + end + end, { "i", "s" }), + }, + + sources = cmp.config.sources { + { name = "path" }, + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "nvim_lua" }, + { name = "copilot" }, + }, +} + vim.diagnostic.config { virtual_text = false, virtual_lines = false, diff --git a/lua/config/format/markdown.lua b/lua/config/format/markdown.lua new file mode 100644 index 0000000..9b36656 --- /dev/null +++ b/lua/config/format/markdown.lua @@ -0,0 +1,55 @@ +local opts = {} + +opts = { + file_types = { "markdown" }, + completions = { + lsp = { + enabled = true, + }, + }, + render_modes = true, + + anti_conceal = { + enabled = true, + above = 1, + below = 1, + }, + + code = { + enabled = true, + render_modes = false, + sign = true, + conceal_delimiters = true, + language = true, + position = "left", + language_icon = true, + language_name = true, + language_info = true, + language_pad = 0, + width = "full", + left_margin = 0, + left_pad = 2, + right_pad = 0, + min_width = 40, + border = "thick", + language_border = "█", + language_left = "", + language_right = "", + above = "▄", + below = "▀", + inline = true, + inline_left = "", + inline_right = "", + inline_pad = 0, + priority = 140, + highlight = "RenderMarkdownCode", + highlight_info = "RenderMarkdownCodeInfo", + highlight_language = nil, + highlight_border = "RenderMarkdownCodeBorder", + highlight_fallback = "RenderMarkdownCodeFallback", + highlight_inline = "RenderMarkdownCodeInline", + style = "full", + }, +} + +return opts diff --git a/lua/config/format/neoformat.lua b/lua/config/format/neoformat.lua index bfbf05e..cef3d24 100644 --- a/lua/config/format/neoformat.lua +++ b/lua/config/format/neoformat.lua @@ -3,7 +3,7 @@ local M = {} M.plugin = { "sbdchd/neoformat", config = function() - vim.g.neoformat_enabled_lua = { "stylua" } + vim.g.neoformat_enabled_lua = { "luaformatter" } vim.g.neoformat_enabled_python = { "black" } vim.g.neoformat_enabled_javascript = { "prettier" } vim.g.neoformat_enabled_typescript = { "prettier" } diff --git a/lua/config/snacks.lua b/lua/config/snacks.lua index cf86bb8..5871313 100644 --- a/lua/config/snacks.lua +++ b/lua/config/snacks.lua @@ -62,7 +62,7 @@ return { scope = { enabled = true }, scroll = { enabled = true }, statuscolumn = { enabled = true }, - words = { enabled = true }, + words = { enabled = false }, terminal = { enabled = true, win = { style = "terminal" }, diff --git a/lua/globals.lua b/lua/globals.lua index f569887..6c8789b 100644 --- a/lua/globals.lua +++ b/lua/globals.lua @@ -6,8 +6,7 @@ vim.g.coq_settings = { keymap = { recommended = false } } vim.g.zig_fmt_parse_errors = 0 vim.g.zig_fmt_autosave = 0 -vim.api.nvim_set_hl(0, 'GitGutterAdd', { fg = '#009900', ctermfg = 2 }) -vim.api.nvim_set_hl(0, 'GitGutterChange', { fg = '#bbbb00', ctermfg = 3 }) -vim.api.nvim_set_hl(0, 'GitGutterDelete', { fg = '#ff2222', ctermfg = 1 }) --- vim.g.gruvbox_material_background = "medium" --- vim.g.gruvbox_material_foreground = "original" +vim.api.nvim_set_hl(0, "GitGutterAdd", { fg = "#009900", ctermfg = 2 }) +vim.api.nvim_set_hl(0, "GitGutterChange", { fg = "#bbbb00", ctermfg = 3 }) +vim.api.nvim_set_hl(0, "GitGutterDelete", { fg = "#ff2222", ctermfg = 1 }) +vim.api.nvim_set_hl(1, "CmpItemKindCopilot", { fg = "#6CC644" }) diff --git a/lua/mappings.lua b/lua/mappings.lua index 8eac304..2e82078 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -36,7 +36,7 @@ end) -- Greatest remap map("n", "Y", [["+Y]]) -map("n", "", function() Snacks.terminal.toggle() end, { desc = "Toggle Terminal" }) +map("n", "", function() Snacks.terminal.toggle() end, { desc = "Toggle Terminal" }) map("n", "gb", function() Snacks.gitbrowse.open() end ) map("n", "K", require("pretty_hover").hover) diff --git a/lua/options.lua b/lua/options.lua index 47c8cad..6dc5822 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -5,7 +5,6 @@ vim.opt.softtabstop = 4 vim.opt.shiftwidth = 4 vim.opt.expandtab = true vim.opt.smartindent = false -vim.opts.rocks.enabled = false vim.o.list = true vim.opt.listchars = { tab = "··", trail = "·", nbsp = "_" } diff --git a/lua/plugins/formatter.lua b/lua/plugins/formatter.lua new file mode 100644 index 0000000..1b2ecb0 --- /dev/null +++ b/lua/plugins/formatter.lua @@ -0,0 +1,12 @@ +return { + { + "MeanderingProgrammer/render-markdown.nvim", + dependencies = { + "nvim-treesitter/nvim-treesitter", + "nvim-mini/mini.nvim", + }, + ---@module 'render-markdown' + ---@type render.md.UserConfig + opts = require "config.format.markdown", + }, +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index accb71c..dabbfef 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -55,7 +55,7 @@ return { "mawkler/modicator.nvim", config = function() require("config.modicator") - end + end, }, { "shinchu/lightline-gruvbox.vim", @@ -86,7 +86,7 @@ return { require "config.notify" end, }, - { + { "zbirenbaum/copilot.lua", cmd = "Copilot", event = "InsertEnter", @@ -94,6 +94,12 @@ return { require "config.ai.copilot" end, }, + { + "zbirenbaum/copilot-cmp", + config = function () + require "config.ai.copilot_cmp" + end, + }, { "CopilotC-Nvim/CopilotChat.nvim", dependencies = {