# per-filetype omni-completion enabled/disabled table
var ftypeOmniCtrlMap: dict<bool> = {}
+var defaultKinds: dict<string> = {
+ 'Text': 't',
+ 'Method': 'm',
+ 'Function': 'f',
+ 'Constructor': 'C',
+ 'Field': 'F',
+ 'Variable': 'v',
+ 'Class': 'c',
+ 'Interface': 'i',
+ 'Module': 'M',
+ 'Property': 'p',
+ 'Unit': 'u',
+ 'Value': 'V',
+ 'Enum': 'e',
+ 'Keyword': 'k',
+ 'Snippet': 'S',
+ 'Color': 'C',
+ 'File': 'f',
+ 'Reference': 'r',
+ 'Folder': 'F',
+ 'EnumMember': 'E',
+ 'Contant': 'd',
+ 'Struct': 's',
+ 'Event': 'E',
+ 'Operator': 'o',
+ 'TypeParameter': 'T'
+}
+
# Returns true if omni-completion is enabled for filetype 'ftype'.
# Otherwise, returns false.
def LspOmniComplEnabled(ftype: string): bool
# Map LSP complete item kind to a character
def LspCompleteItemKindChar(kind: number): string
var kindMap: list<string> = ['',
- 't', # Text
- 'm', # Method
- 'f', # Function
- 'C', # Constructor
- 'F', # Field
- 'v', # Variable
- 'c', # Class
- 'i', # Interface
- 'M', # Module
- 'p', # Property
- 'u', # Unit
- 'V', # Value
- 'e', # Enum
- 'k', # Keyword
- 'S', # Snippet
- 'C', # Color
- 'f', # File
- 'r', # Reference
- 'F', # Folder
- 'E', # EnumMember
- 'd', # Contant
- 's', # Struct
- 'E', # Event
- 'o', # Operator
- 'T' # TypeParameter
- ]
+ 'Text',
+ 'Method',
+ 'Function',
+ 'Constructor',
+ 'Field',
+ 'Variable',
+ 'Class',
+ 'Interface',
+ 'Module',
+ 'Property',
+ 'Unit',
+ 'Value',
+ 'Enum',
+ 'Keyword',
+ 'Snippet',
+ 'Color',
+ 'File',
+ 'Reference',
+ 'Folder',
+ 'EnumMember',
+ 'Contant',
+ 'Struct',
+ 'Event',
+ 'Operator',
+ 'TypeParameter'
+ ]
+
if kind > 25
return ''
endif
- return kindMap[kind]
+
+ var kindName = kindMap[kind]
+ var kindValue = defaultKinds[kindName]
+
+ if opt.lspOptions.customCompletionKinds && opt.lspOptions.completionKinds->has_key(kindName)
+ kindValue = opt.lspOptions.completionKinds[kindName]
+ endif
+
+ return kindValue
enddef
# Remove all the snippet placeholders from 'str' and return the value.
# Use a floating menu to show the code action menu instead of asking for input
usePopupInCodeAction: false,
# ShowReferences in a quickfix list instead of a location list`
- useQuickfixForLocations: false
+ useQuickfixForLocations: false,
+ # Enable support for custom completion kinds
+ customCompletionKinds: false,
+ # A dictionary with all completion kinds that you want to customize
+ completionKinds: {}
}
# set the LSP plugin options from the user provided option values
Need a snippet completion plugin like vim-vsnip.
By default this is set to false.
*lsp-opt-ultisnipsSupport*
-ultisnipsSupport |Boolean| option. Enable SirVer/ultisnips support.
+ultisnipsSupport |Boolean| option. Enable SirVer/ultisnips support.
Need a snippet completion plugin SirVer/ultisnips.
By default this is set to false.
*lsp-opt-usePopupInCodeAction*
command to display the code action for the current
line, use a popup menu instead of echoing.
By default this is set to false.
+ *lsp-opt-customCompletionKinds*
+customCompletionKinds |Boolean| option. If you set this to true, you can set
+ custom completion kinds using the option completionKinds.
+ *lsp-opt-completionKinds*
+completionKinds |Dictionary| option. Here you can set custom completion
+ kinds. To view all completion kind names, use :h lsp-custom-kinds
For example, to disable the automatic placement of signs for the LSP
diagnostic messages, you can add the following line to your .vimrc file: >
contains the LSP Command interface fields. Refer to the LSP specification for
more information about the "Command" interface.
+==============================================================================
+15. Custom LSP Completion Kinds *lsp-custom-kinds*
+
+When a completion popup is triggered, the LSP client will use a default kind
+list to show in the completion "kind" section, to customize it, you need to
+use the option *lsp-opt-customCompletionKinds* and set all custom kinds in the
+option *lsp-opt-completionKinds* . There is a table with all default LSP kinds:
+
+ Kind Name | Value
+------------------------|--------------------
+ Text | t
+ Method | m
+ Function | f
+ Constructor | C
+ Field | F
+ Variable | v
+ Class | c
+ Interface | i
+ Module | M
+ Property | p
+ Unit | u
+ Value | V
+ Enum | e
+ Keyword | k
+ Snippet | S
+ Color | C
+ File | f
+ Reference | r
+ Folder | F
+ EnumMember | E
+ Contant | d
+ Struct | s
+ Event | E
+ Operator | o
+ TypeParameter | T
+
+For example, if you want to change the "Method" kind to the kind "method()":
+
+>
+ vim9script
+
+ LspOptionsSet({
+ customCompletionKinds: true,
+ completionKinds: {
+ "Method": "method()"
+ }
+ })
+<
+
+In the completion popup, will show something like this:
+>
+
+ var file = new File()
+
+ file.cre
+ | create method() |
+ | createIfNotExists method() |
+ | ... |
+
+
vim:tw=78:ts=8:noet:ft=help:norl: