aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua273
1 files changed, 131 insertions, 142 deletions
diff --git a/init.lua b/init.lua
index d58bbba..c710f99 100644
--- a/init.lua
+++ b/init.lua
@@ -3,56 +3,150 @@ vim.cmd('source ~/.vim/vimrc')
3vim.o.termguicolors = true 3vim.o.termguicolors = true
4vim.o.exrc = true 4vim.o.exrc = true
5 5
6vim.o.shadafile = (os.getenv("XDG_CACHE_HOME") or 6if vim.fn.has("win32") then
7 os.getenv("HOME") .. "/.cache" 7 vim.o.shell = 'cmd.exe'
8 ) .. "/vim.shada" 8 vim.opt.rtp:append(vim.fn.expand("$HOME\\scoop\\shims"))
9end
9 10
10-- vimscript: get(environ(), "XDG_CACHE_HOME", "~/.cache")."/vim.shada" 11-- vim.o.shadafile = "/tmp/shada"
11 12
12require'man' 13-- only on Linux...
14-- vim.o.shadafile = (os.getenv("XDG_CACHE_HOME") or
15-- os.getenv("HOME") .. "/.cache"
16-- ) .. "/vim.shada"
17-- vimscript: get(environ(), "XDG_CACHE_HOME", "~/.cache")."/vim.shada"
18-- require'man'
13 19
14require'colorizer'.setup() 20require'colorizer'.setup()
15 21
16-- language servers: 22-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers..
23require('cmp_nvim_lsp').setup{}
24local capabilities = require('cmp_nvim_lsp').default_capabilities()
25
26
27local cmp = require('cmp');
28cmp.setup({
29 snippet = {
30 -- REQUIRED - you must specify a snippet engine
31 expand = function(args)
32 vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
33 -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
34 -- require('snippy').expand_snippet(args.body) -- For `snippy` users.
35 -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
36 end,
37 },
38 window = {
39 completion = cmp.config.window.bordered(),
40 documentation = cmp.config.window.bordered(),
41 },
42 mapping = cmp.mapping.preset.insert({
43 ['<C-b>'] = cmp.mapping.scroll_docs(-4),
44 ['<C-f>'] = cmp.mapping.scroll_docs(4),
45 ["<Tab>"] = cmp.mapping.select_next_item({behavior=cmp.SelectBehavior.Insert}),
46 ["<S-Tab>"] = cmp.mapping.select_prev_item({behavior=cmp.SelectBehavior.Insert}),
47 ['<C-Space>'] = cmp.mapping.complete(),
48 ['<C-e>'] = cmp.mapping.abort(),
49 -- ['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
50
51 ["<CR>"] = cmp.mapping.confirm({
52 behavior = cmp.ConfirmBehavior.Replace,
53 select = true,
54 }),
55
56 ['<C-s>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
57 }),
58 sources = cmp.config.sources({
59 { name = 'nvim_lsp' },
60 { name = 'vsnip' }, -- For vsnip users.
61 -- { name = 'luasnip' }, -- For luasnip users.
62 -- { name = 'ultisnips' }, -- For ultisnips users.
63 -- { name = 'snippy' }, -- For snippy users.
64 }, {
65 { name = 'buffer' },
66 })
67})
68
69-- Set configuration for specific filetype.
70cmp.setup.filetype('gitcommit', {
71 sources = cmp.config.sources({
72 { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
73 }, {
74 { name = 'buffer' },
75 })
76})
77
78-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
79cmp.setup.cmdline({ '/', '?' }, {
80 -- mapping = cmp.mapping.preset.cmdline(),
81 sources = {
82 { name = 'buffer' }
83 }
84})
85
86-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
87cmp.setup.cmdline(':', {
88 -- mapping = cmp.mapping.preset.cmdline(),
89 sources = cmp.config.sources({
90 { name = 'cmdline' }
91 })
92})
93
94
95-- # Language Servers
17-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md 96-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
18 97
98-- The following example advertise capabilities to `clangd`.
19-- C/C++ | clang 99-- C/C++ | clang
20require'lspconfig'.clangd.setup{} 100require('lspconfig')['clangd'].setup{capabilities = capabilities}
21 101
22-- lua 102-- bash | bash-language-server
23require'lspconfig'.sumneko_lua.setup{ 103require('lspconfig')['bashls'].setup{capabilities = capabilities}
24 settings = { 104
25 Lua = { 105-- ccs | vscode-css-languageserver
26 diagnostics = { 106require('lspconfig')['cssls'].setup{capabilities = capabilities}
27 globals = { 'vim' } 107
28 } 108-- rust | rust-analyzer
29 } 109require('lspconfig')['rust_analyzer'].setup{capabilities = capabilities}
30 } 110
31} 111-- javascript | eslint
112require('lspconfig')['eslint'].setup{capabilities = capabilities}
113
114-- javascript | typescript-language-server
115require('lspconfig')['tsserver'].setup{capabilities = capabilities}
116
117-- vimscript | vim-language-server
118require('lspconfig')['vimls'].setup{capabilities = capabilities}
119
120require('lspconfig')['html'].setup{capabilities = capabilities}
121
122require('lspconfig')['jsonls'].setup{capabilities = capabilities}
123
124-- C/C++ | clang
125require('lspconfig')['clangd'].setup{capabilities = capabilities}
32 126
33-- bash | bash-language-server 127-- bash | bash-language-server
34require'lspconfig'.bashls.setup{} 128require('lspconfig')['bashls'].setup{capabilities = capabilities}
35 129
36-- ccs | vscode-css-languageserver 130-- ccs | vscode-css-languageserver
37require'lspconfig'.cssls.setup{} 131require('lspconfig')['cssls'].setup{capabilities = capabilities}
38 132
39-- rust | rust-analyzer 133-- rust | rust-analyzer
40require'lspconfig'.rust_analyzer.setup{} 134require('lspconfig')['rust_analyzer'].setup{capabilities = capabilities}
41 135
42-- javascript | eslint 136-- javascript | eslint
43require'lspconfig'.eslint.setup{} 137require('lspconfig')['eslint'].setup{capabilities = capabilities}
44 138
45-- javascript | typescript-language-server 139-- javascript | typescript-language-server
46require'lspconfig'.tsserver.setup{} 140require('lspconfig')['tsserver'].setup{capabilities = capabilities}
47 141
48-- vimscript | vim-language-server 142-- vimscript | vim-language-server
49require'lspconfig'.vimls.setup{} 143require('lspconfig')['vimls'].setup{capabilities = capabilities}
50 144
51require'lspconfig'.html.setup{} 145require('lspconfig')['html'].setup{capabilities = capabilities}
52 146
53require'lspconfig'.jsonls.setup{} 147require('lspconfig')['jsonls'].setup{capabilities = capabilities}
54 148
55require'lspconfig'.pylsp.setup{ 149require('lspconfig')['pylsp'].setup{
56 settings = { 150 settings = {
57 pylsp = { 151 pylsp = {
58 plugins = { 152 plugins = {
@@ -65,123 +159,16 @@ require'lspconfig'.pylsp.setup{
65 } 159 }
66} 160}
67 161
68 162-- lua
69require'cmp_nvim_lsp'.setup{} 163require('lspconfig')['lua_ls'].setup{
70 164 settings = {
71require'cmp'.setup { 165 Lua = {
72 sources = { 166 diagnostics = {
73 { name = 'nvim_lsp' } 167 globals = { 'vim', 'require', 'cmp' }
74 } 168 }
75} 169 }
76 170 }
77-- -- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers..
78local capabilities = require('cmp_nvim_lsp').default_capabilities()
79--
80-- -- The following example advertise capabilities to `clangd`.
81require'lspconfig'.clangd.setup {
82capabilities = capabilities,
83}
84
85-- Set up nvim-cmp.
86local cmp = require'cmp'
87
88cmp.setup({
89 snippet = {
90 -- REQUIRED - you must specify a snippet engine
91 expand = function(args)
92 vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
93 -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
94 -- require('snippy').expand_snippet(args.body) -- For `snippy` users.
95 -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
96 end,
97 },
98 window = {
99 completion = cmp.config.window.bordered(),
100 documentation = cmp.config.window.bordered(),
101 },
102 mapping = cmp.mapping.preset.insert({
103 ['<C-b>'] = cmp.mapping.scroll_docs(-4),
104 ['<C-f>'] = cmp.mapping.scroll_docs(4),
105 ['<C-Space>'] = cmp.mapping.complete(),
106 ['<C-e>'] = cmp.mapping.abort(),
107 -- ['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
108
109 ["<CR>"] = cmp.mapping.confirm({
110 behavior = cmp.ConfirmBehavior.Replace,
111 select = true,
112 }),
113
114 ['<C-s>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
115 }),
116 sources = cmp.config.sources({
117 { name = 'nvim_lsp' },
118 { name = 'vsnip' }, -- For vsnip users.
119 -- { name = 'luasnip' }, -- For luasnip users.
120 -- { name = 'ultisnips' }, -- For ultisnips users.
121 -- { name = 'snippy' }, -- For snippy users.
122 }, {
123 { name = 'buffer' },
124 })
125})
126
127-- Set configuration for specific filetype.
128cmp.setup.filetype('gitcommit', {
129sources = cmp.config.sources({
130{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
131}, {
132{ name = 'buffer' },
133})
134})
135
136-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
137cmp.setup.cmdline({ '/', '?' }, {
138mapping = cmp.mapping.preset.cmdline(),
139sources = {
140{ name = 'buffer' }
141} 171}
142})
143
144-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
145cmp.setup.cmdline(':', {
146mapping = cmp.mapping.preset.cmdline(),
147sources = cmp.config.sources({
148{ name = 'path' }
149}, {
150{ name = 'cmdline' }
151})
152})
153
154-- -- Set up lspconfig.
155-- local capabilities = require('cmp_nvim_lsp').default_capabilities()
156-- -- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
157-- -- require('lspconfig')['<YOUR_LSP_SERVER>'].setup {
158-- -- }
159--
160-- -- C/C++ | clang
161-- require'lspconfig'.clangd.setup{capabilities = capabilities}
162--
163-- -- bash | bash-language-server
164-- require'lspconfig'.bashls.setup{capabilities = capabilities}
165--
166-- -- ccs | vscode-css-languageserver
167-- require'lspconfig'.cssls.setup{capabilities = capabilities}
168--
169-- -- rust | rust-analyzer
170-- require'lspconfig'.rust_analyzer.setup{capabilities = capabilities}
171--
172-- -- javascript | eslint
173-- require'lspconfig'.eslint.setup{capabilities = capabilities}
174--
175-- -- javascript | typescript-language-server
176-- require'lspconfig'.tsserver.setup{capabilities = capabilities}
177--
178-- -- vimscript | vim-language-server
179-- require'lspconfig'.vimls.setup{capabilities = capabilities}
180--
181-- require'lspconfig'.html.setup{capabilities = capabilities}
182--
183-- require'lspconfig'.jsonls.setup{capabilities = capabilities}
184--
185 172
186 173
187require'nvim-treesitter.configs'.setup { 174require'nvim-treesitter.configs'.setup {
@@ -212,3 +199,5 @@ require'nvim-treesitter.configs'.setup {
212 additional_vim_regex_highlighting = false, 199 additional_vim_regex_highlighting = false,
213 }, 200 },
214} 201}
202
203-- vim: tabstop=2 shiftwidth=2 softtabstop=2
..