Skip to content

Commit

Permalink
feat: Produce completion items with kind = Reference (#363)
Browse files Browse the repository at this point in the history
Previously, no kind was provided, which made editors treat these completions like 'Text' completions.

The problem with text completions is that they can be disabled by users due to their noise. Which then leads to confusion as to why Marksman's completion doesn't work in neovim or something.

Example config recommendation: https://github.com/hrsh7th/nvim-cmp/blob/5dce1b778b85c717f6614e3f4da45e9f19f54435/doc/cmp.txt#L663

Possibly fixes: #204
  • Loading branch information
artempyanykh authored Nov 20, 2024
1 parent 760bd10 commit 1a62211
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Marksman/Compl.fs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ module Completions =
Detail = Some(Doc.pathFromRoot doc |> RelPath.toSystem)
TextEdit = Some(First textEdit)
FilterText = Some filterText
Kind = Some CompletionItemKind.Reference
}
| Some _ ->
let newText = targetLink
Expand All @@ -404,6 +405,7 @@ module Completions =
Detail = Some(Doc.pathFromRoot doc |> RelPath.toSystem)
TextEdit = Some(First textEdit)
FilterText = Some targetName
Kind = Some CompletionItemKind.Reference
}
| _ -> None

Expand Down Expand Up @@ -435,6 +437,7 @@ module Completions =
CompletionItem.Create(completionHeading) with
TextEdit = Some(First textEdit)
FilterText = Some newText
Kind = Some CompletionItemKind.Reference
}
| _ -> None

Expand Down Expand Up @@ -480,6 +483,7 @@ module Completions =
Detail = Some(Doc.pathFromRoot doc |> RelPath.toSystem)
TextEdit = Some(First textEdit)
FilterText = Some filterText
Kind = Some CompletionItemKind.Reference
}
| _ -> None

Expand Down Expand Up @@ -517,6 +521,7 @@ module Completions =
Documentation = MdLinkDef.urlContent def |> Documentation.String |> Some
TextEdit = Some(First textEdit)
FilterText = Some newText
Kind = Some CompletionItemKind.Reference
}

let inlineDoc (pos: Position) (compl: Completable) (doc: Doc) : option<CompletionItem> =
Expand All @@ -533,6 +538,7 @@ module Completions =
Detail = detail
TextEdit =
Some(First { Range = Range.Mk(pos, pos); NewText = targetPathEncoded })
Kind = Some CompletionItemKind.Reference
}
| E(ML { data = MdLink.IL(_, Some url, _) }) ->
match Url.ofUrlNode url with
Expand All @@ -541,6 +547,7 @@ module Completions =
CompletionItem.Create(targetPath) with
Detail = detail
TextEdit = Some(First { Range = url.range; NewText = targetPathEncoded })
Kind = Some CompletionItemKind.Reference
}
| _ -> None
| PE(PartialElement.InlineLink(Some _text, path, Some _anchor, _range)) ->
Expand All @@ -553,6 +560,7 @@ module Completions =
CompletionItem.Create(targetPath) with
Detail = detail
TextEdit = Some(First { Range = range; NewText = targetPathEncoded })
Kind = Some CompletionItemKind.Reference
}
| PE(PartialElement.InlineLink(Some text, _path, None, range)) ->
let newText =
Expand All @@ -563,6 +571,7 @@ module Completions =
Detail = detail
TextEdit = Some(First { Range = range; NewText = newText })
FilterText = Some newText
Kind = Some CompletionItemKind.Reference
}
| _ -> None

Expand All @@ -585,6 +594,7 @@ module Completions =
CompletionItem.Create(completionHeading) with
TextEdit = Some(First { Range = anchor.range; NewText = newText })
FilterText = Some newText
Kind = Some CompletionItemKind.Reference
}
| _ -> None
| PE(PartialElement.InlineLink(Some text, None, Some _anchor, range)) ->
Expand All @@ -594,6 +604,7 @@ module Completions =
CompletionItem.Create(completionHeading) with
TextEdit = Some(First { Range = range; NewText = newText })
FilterText = Some newText
Kind = Some CompletionItemKind.Reference
}
| _ -> None

Expand Down Expand Up @@ -624,6 +635,7 @@ module Completions =
Detail = detail
TextEdit = Some(First { Range = newRange; NewText = newText })
FilterText = Some filterText
Kind = Some CompletionItemKind.Reference
}
| _, _ -> None
| PE(PartialElement.InlineLink(Some text, Some _path, Some _anchor, range)) ->
Expand All @@ -637,6 +649,7 @@ module Completions =
Detail = detail
TextEdit = Some(First { Range = range; NewText = newText })
FilterText = Some filterText
Kind = Some CompletionItemKind.Reference
}
| _ -> None

Expand All @@ -663,6 +676,7 @@ module Completions =
CompletionItem.Create(label) with
Detail = Some detail
TextEdit = Some(First { Range = range; NewText = label })
Kind = Some CompletionItemKind.Reference
}

module Candidates =
Expand Down

0 comments on commit 1a62211

Please sign in to comment.