@@ -118,21 +118,19 @@ impl LanguageServer for Backend {
118118
119119 let trie_lock = self . trie . lock ( ) . await ;
120120 let words = trie_lock. suggest_completions ( & prefix) ;
121- let mut all_words = words;
121+ let suffixes = get_possible_current_word ( & current_line, position. character as i32 ) ;
122+ words_to_completion_items ( words, & suffixes, & mut completions, CompletionItemKind :: TEXT ) ;
122123
123124 let tmux_words = self . prepare_tmux_words ( ) . await ;
124- all_words . extend ( tmux_words) ;
125+ words_to_completion_items ( tmux_words, & suffixes , & mut completions , CompletionItemKind :: REFERENCE ) ;
125126
126127 if self . lsp_args . command_source {
127- let command_words = get_command_completions ( ) ;
128- all_words. extend ( command_words) ;
128+ let mut command_words = get_command_completions ( ) ;
129+ command_words. sort ( ) ;
130+ command_words. dedup ( ) ;
131+ words_to_completion_items ( command_words, & suffixes, & mut completions, CompletionItemKind :: KEYWORD ) ;
129132 }
130133
131- let suffixes = get_possible_current_word ( & current_line, position. character as i32 ) ;
132- all_words. sort ( ) ;
133- all_words. dedup ( ) ;
134- words_to_completion_items ( all_words, & suffixes, & mut completions) ;
135-
136134 let file_uri = params. text_document_position . text_document . uri . to_string ( ) ;
137135 let snippets = self . suggest_snippets ( & file_uri, & prefix) . await ;
138136 snippets_to_completion_items ( snippets, & mut completions) ;
@@ -209,7 +207,7 @@ impl Backend {
209207
210208 async fn maybe_update_tmux ( & self ) {
211209 if self . lsp_args . tmux_source {
212- let tmux_content = retrieve_tmux_words ( ) ;
210+ let tmux_content = retrieve_tmux_words ( self . lsp_args . min_word_len ) ;
213211 let mut data = self . tmux_source . lock ( ) . await ;
214212 data. clear ( ) ;
215213 data. extend ( tmux_content) ;
0 commit comments