@@ -5,66 +5,75 @@ local function config()
55 -- For a list of support completion plugins,
66 -- see https://github.com/hrsh7th/nvim-cmp/wiki/List-of-sources
77 local cmp = require (' cmp' )
8- cmp .setup ({
9- sources = {
10- { name = ' nvim_lsp' , keyword_length = 1 },
11- { name = ' buffer' },
12- { name = ' path' },
13- { name = ' bufname' },
14- { name = ' buffer-lines' , option = {
15- leading_whitespace = true
16- }},
17- { name = ' calc' },
18- { name = ' rpncalc' },
19- { name = ' dictionary' , keyword_length = 2 },
20- { name = ' omni' , option = {
21- disable_omnifuncs = {' v:lua.vim.lsp.omnifunc' }
22- }},
23- { name = ' spell' , option = {
24- keep_all_entries = false ,
25- enable_in_context = function ()
26- return true
27- end ,
28- preselect_correc_word = true
29- }}
8+ cmp .setup (
9+ {
10+ sources = {
11+ { name = ' nvim_lsp' , keyword_length = 1 },
12+ { name = ' buffer' },
13+ { name = ' path' },
14+ { name = ' bufname' },
15+ { name = ' buffer-lines' , option = {
16+ leading_whitespace = true
17+ }},
18+ { name = ' nvim_lsp_signature_help' },
19+ { name = ' calc' },
20+ { name = ' rpncalc' },
21+ { name = ' dictionary' , keyword_length = 2 },
22+ { name = ' omni' , option = {
23+ disable_omnifuncs = {' v:lua.vim.lsp.omnifunc' }
24+ }},
25+ { name = ' spell' , option = {
26+ keep_all_entries = false ,
27+ enable_in_context = function ()
28+ return true
29+ end ,
30+ preselect_correc_word = true
31+ }}
32+ }
3033 }
31- })
32- -- setup completion for '/' search
33- cmp .setup .cmdline (' /' , {
34- mapping = cmp .mapping .preset .cmdline (),
35- sources = {
36- -- cmp-cmdline offers completion based on current buffer
37- { name = ' buffer' }
38- }
39- })
40- -- setup completion for command mode
41- cmp .setup .cmdline (' :' , {
42- mapping = cmp .mapping .preset .cmdline (),
43- sources = cmp .config .sources (
34+ )
35+ -- setup completion for '/' and '?' search
36+ cmp .setup .cmdline (
37+ { ' /' , ' ?' },
4438 {
45- -- cmp-cmdline offers completion based on paths
46- { name = ' path' }
47- },
39+ mapping = cmp .mapping .preset .cmdline (),
40+ sources = cmp .config .sources (
41+ {
42+ -- offers completion based on current buffer's words
43+ {
44+ name = ' buffer' ,
45+ option = { keyword_pattern = [[ \k\+]] } -- recognize words
46+ }
47+ },
48+ {
49+ -- offers completion based on current buffer's lines unless words source is available
50+ {
51+ name = " buffer-lines"
52+ }
53+ }
54+ )
55+ }
56+ )
57+ -- setup completion for command mode
58+ cmp .setup .cmdline (
59+ {' :' },
4860 {
49- {
50- name = ' cmdline' ,
51- option = {
52- ignore_cmds = { ' Man' , ' !' }
61+ mapping = cmp .mapping .preset .cmdline (),
62+ sources = {
63+ -- offers completion based on paths
64+ {
65+ name = ' path'
66+ },
67+ -- offers completion based on cmdline
68+ {
69+ name = ' cmdline' ,
70+ option = {
71+ ignore_cmds = { ' Man' , ' !' }
72+ }
73+ }
5374 }
54- }
55- })
56- })
57- -- setup completion for / and ? in the command line
58- cmp .setup .cmdline ({ " /" , " ?" }, {
59- mapping = cmp .mapping .preset .cmdline (),
60- sources = {
61- {
62- name = " buffer" ,
63- option = { keyword_pattern = [[ \k\+]] }
64- },
65- { name = " buffer-lines" }
6675 }
67- } )
76+ )
6877 -- View cmp sources status with :CmpStatus
6978end
7079
0 commit comments