Fix keymap conflicts and add improvements
- Fix duplicate git conflict keymaps (centralized in gitconflict.lua) - Fix duplicate Copilot keymaps (centralized in copilot.lua) - Change insert mode escape from 'jk' to 'jj' to avoid typing conflicts - Add word counter to statusline (lualine) - Disable Copilot by default for .tex files - Remove textwidth limits for visual wrapping based on window width - Add comprehensive improvements documentation (IMPROVEMENTS.md) - Update README with links to documentation
This commit is contained in:
@@ -8,13 +8,6 @@ return {
|
||||
panel = {
|
||||
enabled = true,
|
||||
auto_refresh = false,
|
||||
keymap = {
|
||||
jump_prev = "[[",
|
||||
jump_next = "]]",
|
||||
accept = "<CR>",
|
||||
refresh = "gr",
|
||||
open = "<M-CR>",
|
||||
},
|
||||
layout = {
|
||||
position = "bottom", -- | top | left | right
|
||||
ratio = 0.4,
|
||||
@@ -24,14 +17,6 @@ return {
|
||||
enabled = true,
|
||||
auto_trigger = true, -- Enable auto-trigger suggestions as you type
|
||||
debounce = 75,
|
||||
keymap = {
|
||||
accept = "<M-l>",
|
||||
accept_word = false,
|
||||
accept_line = false,
|
||||
next = "<leader>]", -- Use leader key for next suggestion
|
||||
prev = "<leader>[", -- Use leader key for previous suggestion
|
||||
dismiss = "<C-]>",
|
||||
},
|
||||
},
|
||||
filetypes = {
|
||||
markdown = true,
|
||||
@@ -41,11 +26,27 @@ return {
|
||||
hgcommit = true,
|
||||
svn = true,
|
||||
cvs = true,
|
||||
tex = false, -- Disable Copilot for LaTeX files by default
|
||||
["."] = true,
|
||||
},
|
||||
copilot_node_command = "node", -- Node.js version must be > 16.x
|
||||
server_opts_overrides = {},
|
||||
})
|
||||
|
||||
-- Disable Copilot when opening .tex files
|
||||
vim.api.nvim_create_autocmd({ "FileType", "BufEnter" }, {
|
||||
pattern = "tex",
|
||||
callback = function()
|
||||
-- Safely dismiss any active suggestions
|
||||
local ok, suggestion = pcall(require, "copilot.suggestion")
|
||||
if ok and suggestion and suggestion.is_visible() then
|
||||
suggestion.dismiss()
|
||||
end
|
||||
-- Disable Copilot for this buffer
|
||||
vim.cmd("Copilot disable")
|
||||
end,
|
||||
desc = "Disable Copilot for LaTeX files",
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -49,12 +49,44 @@ return {
|
||||
},
|
||||
}
|
||||
|
||||
-- Custom word/character counter function
|
||||
local function word_count()
|
||||
-- Skip for very large files to avoid performance issues
|
||||
local line_count = vim.api.nvim_buf_line_count(0)
|
||||
if line_count > 10000 then
|
||||
return ""
|
||||
end
|
||||
|
||||
local words = 0
|
||||
local chars = 0
|
||||
|
||||
-- Get all lines at once for better performance
|
||||
local all_lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
|
||||
|
||||
for _, line in ipairs(all_lines) do
|
||||
if line and #line > 0 then
|
||||
-- Count words (non-whitespace sequences)
|
||||
for _ in line:gmatch("%S+") do
|
||||
words = words + 1
|
||||
end
|
||||
-- Count characters (excluding newline)
|
||||
chars = chars + #line
|
||||
end
|
||||
end
|
||||
|
||||
-- Format: show words and characters
|
||||
return string.format("%d words, %d chars", words, chars)
|
||||
end
|
||||
|
||||
-- configure lualine with modified theme
|
||||
lualine.setup({
|
||||
options = {
|
||||
theme = my_lualine_theme,
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { "mode" },
|
||||
lualine_b = { "branch", "diff", "diagnostics" },
|
||||
lualine_c = { "filename" },
|
||||
lualine_x = {
|
||||
{
|
||||
lazy_status.updates,
|
||||
@@ -65,6 +97,22 @@ return {
|
||||
{ "fileformat" },
|
||||
{ "filetype" },
|
||||
},
|
||||
lualine_y = { "progress" },
|
||||
lualine_z = {
|
||||
{
|
||||
word_count,
|
||||
color = { fg = colors.fg },
|
||||
},
|
||||
{ "location" },
|
||||
},
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = { "filename" },
|
||||
lualine_b = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
lualine_y = {},
|
||||
lualine_z = { "location" },
|
||||
},
|
||||
})
|
||||
end,
|
||||
|
||||
@@ -47,17 +47,17 @@ return {
|
||||
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
||||
["<C-e>"] = cmp.mapping.abort(), -- close completion window
|
||||
["<CR>"] = cmp.mapping.confirm({ select = false }),
|
||||
-- Tab to accept Copilot suggestions, fallback to snippet expansion
|
||||
-- Tab for completion menu and snippet expansion
|
||||
-- Note: Copilot suggestion acceptance is handled in keymaps/copilot.lua
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
-- Handle nvim-cmp completion menu
|
||||
if cmp.visible() then
|
||||
local entry = cmp.get_selected_entry()
|
||||
-- If Copilot suggestion is available and selected, accept it
|
||||
if entry and entry.source.name == "copilot" then
|
||||
cmp.confirm({ select = true })
|
||||
else
|
||||
-- Check if we can find a Copilot entry in the completion menu
|
||||
-- Since Copilot has high priority (900), it's likely near the top
|
||||
-- Just confirm the current selection (Copilot will be selected if available)
|
||||
-- Confirm the current selection
|
||||
cmp.confirm({ select = true })
|
||||
end
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
|
||||
Reference in New Issue
Block a user