aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua271
1 files changed, 69 insertions, 202 deletions
diff --git a/init.lua b/init.lua
index 2dc45ee..a68778d 100644
--- a/init.lua
+++ b/init.lua
@@ -1,213 +1,80 @@
1vim.cmd('source ~/.vim/vimrc') 1--------------------------------------------------------------------------------
2 2-- vim options, first sourced from vimrc, then appended by Neovim specific stuff
3vim.opt.termguicolors = true 3--------------------------------------------------------------------------------
4vim.opt.exrc = true 4local configdir = vim.fn.fnamemodify(vim.fn.expand("$MYVIMRC"), ":p:h")
5vim.opt.foldmethod = 'syntax' 5vim.cmd('source ' .. configdir .. '/vimrc')
6 6
7if vim.fn.has("win32") then 7vim.opt.encoding='utf-8'
8 vim.opt.rtp:append(vim.fn.expand("$HOME\\scoop\\shims")) 8vim.opt.inccommand = "nosplit" -- Neovim only: preview substitute and such things in real time
9vim.opt.shadafile = configdir .. "/shada.file"
10
11--------------------------------------------------------------------------------
12-- Bootstrap lazy.nvim
13--------------------------------------------------------------------------------
14local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
15if not (vim.uv or vim.loop).fs_stat(lazypath) then
16 local lazyrepo = "https://github.com/folke/lazy.nvim.git"
17 local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
18 if vim.v.shell_error ~= 0 then
19 vim.api.nvim_echo({
20 { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
21 { out, "WarningMsg" },
22 { "\nPress any key to exit..." },
23 }, true, {})
24 vim.fn.getchar()
25 os.exit(1)
26 end
9end 27end
28vim.opt.rtp:prepend(lazypath)
10 29
11vim.opt.runtimepath:remove("/usr/share/vim/vimfiles") 30require("lazy").setup({
12vim.keymap.set('n', '<F12>', ':Buffers<CR>') 31 spec = {
13 32 { import = "plugins", },
14 33 'coderonline/vim-fancy-line',
15 34 'coderonline/vim-recently-used',
16-- vim.o.shadafile = "/tmp/shada"
17
18-- only on Linux...
19-- vim.o.shadafile = (os.getenv("XDG_CACHE_HOME") or
20-- os.getenv("HOME") .. "/.cache"
21-- ) .. "/vim.shada"
22-- vimscript: get(environ(), "XDG_CACHE_HOME", "~/.cache")."/vim.shada"
23-- require'man'
24
25require'colorizer'.setup()
26
27-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers..
28require('cmp_nvim_lsp').setup{}
29local capabilities = require('cmp_nvim_lsp').default_capabilities()
30
31
32local cmp = require('cmp');
33cmp.setup({
34 snippet = {
35 -- REQUIRED - you must specify a snippet engine
36 expand = function(args)
37 vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
38 -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
39 -- require('snippy').expand_snippet(args.body) -- For `snippy` users.
40 -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
41 end,
42 },
43 window = {
44 completion = cmp.config.window.bordered(),
45 documentation = cmp.config.window.bordered(),
46 },
47 mapping = cmp.mapping.preset.insert({
48 ['<C-b>'] = cmp.mapping.scroll_docs(-4),
49 ['<C-f>'] = cmp.mapping.scroll_docs(4),
50 ["<Tab>"] = cmp.mapping.select_next_item({behavior=cmp.SelectBehavior.Insert}),
51 ["<S-Tab>"] = cmp.mapping.select_prev_item({behavior=cmp.SelectBehavior.Insert}),
52 ['<C-Space>'] = cmp.mapping.complete(),
53 ['<C-e>'] = cmp.mapping.abort(),
54 -- ['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
55
56 ["<CR>"] = cmp.mapping.confirm({
57 behavior = cmp.ConfirmBehavior.Replace,
58 select = true,
59 }),
60
61 ['<C-s>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
62 }),
63 sources = cmp.config.sources({
64 { name = 'nvim_lsp' },
65 { name = 'vsnip' }, -- For vsnip users.
66 -- { name = 'luasnip' }, -- For luasnip users.
67 -- { name = 'ultisnips' }, -- For ultisnips users.
68 -- { name = 'snippy' }, -- For snippy users.
69 }, {
70 { name = 'buffer' },
71 })
72})
73
74-- Set configuration for specific filetype.
75cmp.setup.filetype('gitcommit', {
76 sources = cmp.config.sources({
77 { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
78 }, {
79 { name = 'buffer' },
80 })
81})
82
83-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
84cmp.setup.cmdline({ '/', '?' }, {
85 -- mapping = cmp.mapping.preset.cmdline(),
86 sources = {
87 { name = 'buffer' }
88 } 35 }
89}) 36})
90 37
91-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). 38-- Restore cursor position
92cmp.setup.cmdline(':', { 39vim.api.nvim_create_autocmd({ "BufReadPost" }, {
93 -- mapping = cmp.mapping.preset.cmdline(), 40 callback = function() vim.cmd('silent! normal! g`"zv') end
94 sources = cmp.config.sources({
95 { name = 'cmdline' }
96 })
97}) 41})
98 42
43-- LSP says 'fix available', but there is no such command? Let us fix that:
44vim.api.nvim_create_user_command(
45 'LspFix',
46 function()
47 vim.lsp.buf.code_action()
48 end, {}
49)
50
51-- speaking of lsp, lets enable logging (TODO: remove if you remove
52-- `lua/cmp.lua`, but why would you?)
53vim.g.lsp_log_verbose = 1
54vim.g.lsp_log_file = configdir .. ('/vim-lsp.log')
55vim.lsp.set_log_level 'error'
56if vim.fn.has 'nvim-0.5.1' == 1 then
57 require('vim.lsp.log').set_format_func(vim.inspect)
58end
99 59
100-- # Language Servers 60-- If you need scoop for some dependencies on Windows machines this may come
101-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md 61-- handy:
102 62if vim.fn.has("win32") then
103-- The following example advertise capabilities to `clangd`. 63 vim.opt.rtp:append(vim.fn.expand("$HOME\\scoop\\shims"))
104-- C/C++ | clang 64end
105require('lspconfig')['clangd'].setup{capabilities = capabilities}
106
107-- bash | bash-language-server
108require('lspconfig')['bashls'].setup{capabilities = capabilities}
109
110-- ccs | vscode-css-languageserver
111require('lspconfig')['cssls'].setup{capabilities = capabilities}
112
113-- rust | rust-analyzer
114require('lspconfig')['rust_analyzer'].setup{capabilities = capabilities}
115
116-- javascript | eslint
117require('lspconfig')['eslint'].setup{capabilities = capabilities}
118
119-- javascript | typescript-language-server
120require('lspconfig')['tsserver'].setup{capabilities = capabilities}
121
122-- vimscript | vim-language-server
123require('lspconfig')['vimls'].setup{capabilities = capabilities}
124
125require('lspconfig')['html'].setup{capabilities = capabilities}
126
127require('lspconfig')['jsonls'].setup{capabilities = capabilities}
128
129-- C/C++ | clang
130require('lspconfig')['clangd'].setup{capabilities = capabilities}
131
132-- bash | bash-language-server
133require('lspconfig')['bashls'].setup{capabilities = capabilities}
134
135-- ccs | vscode-css-languageserver
136require('lspconfig')['cssls'].setup{capabilities = capabilities}
137
138-- rust | rust-analyzer
139require('lspconfig')['rust_analyzer'].setup{capabilities = capabilities}
140
141-- javascript | eslint
142require('lspconfig')['eslint'].setup{capabilities = capabilities}
143
144-- javascript | typescript-language-server
145require('lspconfig')['tsserver'].setup{capabilities = capabilities}
146
147-- vimscript | vim-language-server
148require('lspconfig')['vimls'].setup{capabilities = capabilities}
149
150require('lspconfig')['html'].setup{capabilities = capabilities}
151
152require('lspconfig')['jsonls'].setup{capabilities = capabilities}
153
154require('lspconfig')['pylsp'].setup{
155 settings = {
156 pylsp = {
157 plugins = {
158 pycodestyle = {
159 ignore = {'W391'},
160 maxLineLength = 100
161 }
162 }
163 }
164 }
165}
166
167-- lua
168require('lspconfig')['lua_ls'].setup{
169 settings = {
170 Lua = {
171 diagnostics = {
172 globals = { 'vim', 'require', 'cmp' }
173 }
174 }
175 }
176}
177
178
179require'nvim-treesitter.configs'.setup {
180 -- A list of parser names, or "all"
181 ensure_installed = { "c", "bash", "javascript" },
182
183 -- Install parsers synchronously (only applied to `ensure_installed`)
184 sync_install = false,
185
186 -- Automatically install missing parsers when entering buffer
187 -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
188 auto_install = true,
189
190 -- List of parsers to ignore installing (for "all")
191 ignore_install = { "javascript" },
192
193 ---- If you need to change the installation directory of the parsers (see -> Advanced Setup)
194 -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")!
195
196 highlight = {
197 -- `false` will disable the whole extension
198 enable = true,
199
200 -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
201 -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
202 -- Using this option may slow down your editor, and you may see some duplicate highlights.
203 -- Instead of true it can also be a list of languages
204 additional_vim_regex_highlighting = false,
205 },
206}
207
208-- vim.wo.foldtext = 'v:lua.vim.treesitter.foldtext()' -- not available yet in my installation
209vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
210vim.wo.foldlevel = 1
211 65
66if vim.g.neovide then
67 vim.guifont = "monospace:h11:b"
68 vim.g.neovide_cursor_animation_length = 0.03
69 vim.g.neovide_cursor_trail_size = 0.8
70 vim.g.neovide_scroll_animation_length = 0.05
71 vim.g.neovide_transparency = 0.9
72 vim.g.neovide_cursor_animation_length=0
73 vim.g.neovide_cursor_vfx_mode = ""
74 vim.g.neovide_floating_blur_amount_x = 4.0
75 vim.g.neovide_floating_blur_amount_y = 4.0
76 vim.g.neovide_background_color = '#383a62'
77 vim.g.neovide_scale_factor = 1.0
78end
212 79
213-- vim: tabstop=2 shiftwidth=2 softtabstop=2 80-- vim: tabstop=2 shiftwidth=2 softtabstop=2
..