From c1c13ef2d2d191f2393c9082f4d5f0be368909f9 Mon Sep 17 00:00:00 2001 From: luozhiya Date: Fri, 7 Jun 2024 10:15:05 +0800 Subject: [PATCH] Set `disable_completion_within_the_line` --- lua/fittencode/config.lua | 10 +++------- lua/fittencode/sessions.lua | 2 +- lua/fittencode/views/lines.lua | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lua/fittencode/config.lua b/lua/fittencode/config.lua index ebceda66..38ab9d41 100644 --- a/lua/fittencode/config.lua +++ b/lua/fittencode/config.lua @@ -144,13 +144,6 @@ local defaults = { }, } --- Private options -M.internal = { - virtual_text = { - inline = vim.fn.has('nvim-0.10') == 1, - }, -} - ---@param opts? FittenCodeOptions function M.setup(opts) ---@class FittenCodeOptions @@ -159,6 +152,9 @@ function M.setup(opts) M.options.keymaps.inline = {} M.options.keymaps.chat = {} end + if vim.fn.has('nvim-0.10') ~= 1 then + M.options.inline_completion.disable_completion_within_the_line = true + end end return M diff --git a/lua/fittencode/sessions.lua b/lua/fittencode/sessions.lua index c5ad4466..e43c7893 100644 --- a/lua/fittencode/sessions.lua +++ b/lua/fittencode/sessions.lua @@ -112,7 +112,7 @@ local function make_generate_one_stage_params(opts) if prompt == nil then return end - if prompt.within_the_line and (not Config.internal.virtual_text.inline or Config.options.inline_completion.disable_completion_within_the_line) then + if prompt.within_the_line and Config.options.inline_completion.disable_completion_within_the_line then return end local fc_prompt = '!FCPREFIX!' .. prompt.prefix .. '!FCSUFFIX!' .. prompt.suffix .. '!FCMIDDLE!' diff --git a/lua/fittencode/views/lines.lua b/lua/fittencode/views/lines.lua index a45522a3..432a89ab 100644 --- a/lua/fittencode/views/lines.lua +++ b/lua/fittencode/views/lines.lua @@ -83,7 +83,7 @@ local function set_extmark(virt_text, hl_mode) local row, col = Base.get_cursor() local ids = {} - if Config.internal.virtual_text.inline then + if vim.fn.has('nvim-0.10') == 1 then ids[#ids + 1] = api.nvim_buf_set_extmark(0, namespace, row, col, { virt_text = virt_text[1], virt_text_pos = 'inline',