diff --git a/after/plugin/completion.lua b/after/plugin/completion.lua new file mode 100644 index 0000000..ce44408 --- /dev/null +++ b/after/plugin/completion.lua @@ -0,0 +1,90 @@ +-- Configure Completion + +vim.opt.completeopt = {"menu","menuone","noselect"} +vim.opt.shortmess:append "c" + +local ok, lspkind = pcall(require, "lspkind") +if not ok then + return +end + +lspkind.init() + +local luasnip = require("luasnip") +local cmp = require("cmp") + +local has_words_before = function() + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil +end + +cmp.setup { + mapping = { + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, + [""] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping( + cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }) + }, + sources = { + {name = "nvim_lua"}, + {name = "nvim_lsp"}, + {name = "path"}, + {name = "luasnip"}, + { + name = "buffer", + option = { + keyword_length = 5, + }, + }, + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + experimental = { + native_menu = false, + ghost_text = true, + }, + formatting = { + format = lspkind.cmp_format { + mode = 'symbol_text', + menu = { + buffer = "[BUF]", + nvim_lsp = "[LSP]", + nvim_lua = "[API]", + path = "[PTH]", + luasnip = "[SNP]" + } + } + } +} + + + diff --git a/after/plugin/luasnips.lua b/after/plugin/luasnips.lua new file mode 100644 index 0000000..e22fb4c --- /dev/null +++ b/after/plugin/luasnips.lua @@ -0,0 +1,21 @@ +if not pcall(require,"luasnip") then + print("NO SNIPS?") + return +end + +local ls = require "luasnip" +-- local types = require "luasnip.util.types" + + +ls.config.set_config{ + + -- remember the last snippet + history = true, + + -- make dynamic snippets update with typing + updateevents = "TextChanged,TextChangedI", + + --Autosnippets: + enable_autosnippets = true, +} +require("luasnip/loaders/from_vscode").load() diff --git a/after/plugin/treesitter.lua b/after/plugin/treesitter.lua new file mode 100644 index 0000000..5b83c14 --- /dev/null +++ b/after/plugin/treesitter.lua @@ -0,0 +1,30 @@ +if not pcall(require, "nvim-treesitter") then + return +end + +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" + ensure_installed = { "c", "lua", "rust", "c_sharp", "markdown", "latex" }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + highlight = { + -- `false` will disable the whole extension + enable = true, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same + -- time. Set this to `true` if you depend on 'syntax' being enabled (like + -- for indentation). Using this option may slow down your editor, and you + -- may see some duplicate highlights. Instead of true it can also be a list + -- of languages + additional_vim_regex_highlighting = false, + }, + + rainbow = { + enable = true, + extended_mode = true, + max_file_lines = nil, + } +} +