Skip to content

Commit 3510b84

Browse files
authored
style: naming-convention (#32)
add plugin prefix * `CopilotLsp` for highlight groups * `copilotlsp.` for augroups, namespace and type annotations
1 parent f81dfa3 commit 3510b84

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

lsp/copilot_ls.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ return {
3030
}),
3131
root_dir = vim.uv.cwd(),
3232
on_init = function(client)
33-
vim.api.nvim_set_hl(0, "NesAdd", { link = "DiffAdd", default = true })
34-
vim.api.nvim_set_hl(0, "NesDelete", { link = "DiffDelete", default = true })
35-
vim.api.nvim_set_hl(0, "NesApply", { link = "DiffText", default = true })
33+
vim.api.nvim_set_hl(0, "CopilotLspNesAdd", { link = "DiffAdd", default = true })
34+
vim.api.nvim_set_hl(0, "CopilotLspNesDelete", { link = "DiffDelete", default = true })
35+
vim.api.nvim_set_hl(0, "CopilotLspNesApply", { link = "DiffText", default = true })
3636

37-
local au = vim.api.nvim_create_augroup("copilot-language-server", { clear = true })
37+
local au = vim.api.nvim_create_augroup("copilotlsp.init", { clear = true })
3838
--NOTE: Inline Completions
3939
--TODO: We dont currently use this code path, so comment for now until a UI is built
4040
-- vim.api.nvim_create_autocmd("TextChangedI", {

lua/copilot-lsp/nes/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local utils = require("copilot-lsp.util")
44

55
local M = {}
66

7-
local nes_ns = vim.api.nvim_create_namespace("copilot-nes")
7+
local nes_ns = vim.api.nvim_create_namespace("copilotlsp.nes")
88

99
---@param err lsp.ResponseError?
1010
---@param result copilotlsp.copilotInlineEditResponse

lua/copilot-lsp/nes/ui.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ end
3131

3232
---@private
3333
---@param suggestion copilotlsp.InlineEdit
34-
---@return nes.LineCalculationResult
34+
---@return copilotlsp.nes.LineCalculationResult
3535
function M._calculate_lines(suggestion)
3636
local deleted_lines_count = suggestion.range["end"].line - suggestion.range.start.line
3737
local added_lines = vim.split(trim_end(suggestion.newText), "\n")
@@ -54,7 +54,7 @@ function M._calculate_lines(suggestion)
5454
-- end
5555

5656
-- Calculate positions for delete highlight extmark
57-
---@type nes.DeleteExtmark
57+
---@type copilotlsp.nes.DeleteExtmark
5858
local delete_extmark = {
5959
row = suggestion.range.start.line,
6060
end_row = (
@@ -64,7 +64,7 @@ function M._calculate_lines(suggestion)
6464
}
6565

6666
-- Calculate positions for virtual lines extmark
67-
---@type nes.VirtLinesExtmark
67+
---@type copilotlsp.nes.AddExtmark
6868
local virt_lines_extmark = {
6969
row = (
7070
suggestion.range["end"].character ~= 0 and suggestion.range["end"].line
@@ -104,7 +104,7 @@ function M._display_next_suggestion(edits, ns_id)
104104
if lines.deleted_lines_count > 0 then
105105
-- Deleted range red highlight
106106
vim.api.nvim_buf_set_extmark(bufnr, ns_id, lines.delete_extmark.row, 0, {
107-
hl_group = "NesDelete",
107+
hl_group = "CopilotLspNesDelete",
108108
end_row = lines.delete_extmark.end_row,
109109
})
110110
end

lua/copilot-lsp/types.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@
88
---@class copilotlsp.copilotInlineEditResponse
99
---@field edits copilotlsp.InlineEdit[]
1010

11-
---@class nes.EditSuggestionUI
11+
---@class copilotlsp.nes.EditSuggestionUI
1212
---@field preview_winnr? integer
1313

14-
---@class nes.DeleteExtmark
14+
---@class copilotlsp.nes.DeleteExtmark
1515
--- Holds row information for delete highlight extmark.
1616
---@field row number
1717
---@field end_row number
1818

19-
---@class nes.VirtLinesExtmark
19+
---@class copilotlsp.nes.AddExtmark
2020
-- Holds row and virtual lines count for virtual lines extmark.
2121
---@field row number
2222
---@field virt_lines_count number
2323

24-
---@class nes.LineCalculationResult
24+
---@class copilotlsp.nes.LineCalculationResult
2525
--- The result of calculating lines for inline suggestion UI.
2626
---@field deleted_lines_count number
2727
---@field added_lines string[]
2828
---@field added_lines_count number
2929
---@field same_line number
30-
---@field delete_extmark nes.DeleteExtmark
31-
---@field virt_lines_extmark nes.VirtLinesExtmark
30+
---@field delete_extmark copilotlsp.nes.DeleteExtmark
31+
---@field virt_lines_extmark copilotlsp.nes.AddExtmark

lua/copilot-lsp/util.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ end
109109
function M.hl_text_to_virt_lines(text, lang)
110110
local lines = vim.split(text, "\n")
111111
local normal_hl = "Normal"
112-
local bg_hl = "NesAdd"
112+
local bg_hl = "CopilotLspNesAdd"
113113

114114
local function hl_chunk(chunk, hl)
115115
if not hl then

tests/nes/test_nes.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ T["nes"]["highlights replacement"] = function()
112112
child.lua_func(function()
113113
vim.cmd([[colorscheme vim]])
114114
vim.treesitter.start(0)
115-
vim.cmd([[hi! NesAdd guifg=NONE guibg=NONE]])
116-
vim.cmd([[hi! NesDelete guifg=NONE guibg=NONE]])
115+
vim.cmd([[hi! CopilotLspNesAdd guifg=NONE guibg=NONE]])
116+
vim.cmd([[hi! CopilotLspNesDelete guifg=NONE guibg=NONE]])
117117
end)
118118
ref(child.get_screenshot())
119119
vim.uv.sleep(500)

tests/nes/test_ui.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ local nes_ui = require("copilot-lsp.nes.ui")
44
local T = MiniTest.new_set()
55

66
T["diff placement calculations"] = MiniTest.new_set({
7-
---@type [ copilotlsp.InlineEdit, nes.LineCalculationResult][]
7+
---@type [ copilotlsp.InlineEdit, copilotlsp.nes.LineCalculationResult][]
88
parametrize = {
99
{
1010
--- Same line edit
@@ -149,7 +149,7 @@ T["diff placement calculations"] = MiniTest.new_set({
149149

150150
T["diff placement calculations"]["calculates locations"] =
151151
---@param edit copilotlsp.InlineEdit
152-
---@param result nes.LineCalculationResult
152+
---@param result copilotlsp.nes.LineCalculationResult
153153
function(edit, result)
154154
local placement = nes_ui._calculate_lines(edit)
155155
eq(result, placement)

0 commit comments

Comments
 (0)