diff --git a/nvim/init.lua b/nvim/init.lua index a609663..d3fa8ef 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,37 +1,82 @@ vim.opt.number = true vim.opt.relativenumber = true -vim.cmd 'colorscheme habamax' - vim.opt.expandtab = true vim.opt.tabstop = 8 vim.opt.softtabstop = 0 vim.opt.shiftwidth = 4 vim.opt.smarttab = true vim.opt.autoindent = true +vim.opt.mouse = "a" -vim.opt.mouse = 'a' +vim.cmd("colorscheme habamax") -vim.o.completeopt = "menuone,noinsert,noselect,preview" +local servers = { + clangd = {} +} -vim.api.nvim_create_autocmd('FileType', { - pattern = 'c', - callback = function(args) - vim.lsp.start({ - name = 'clangd', - cmd = {'clangd'}, - root_dir = vim.fn.expand("."), - }) - end, -}) +local mini_path = vim.fn.stdpath("data") .. "/site/pack/deps/start/mini.nvim" +if not vim.loop.fs_stat(mini_path) then + vim.fn.system({ + "git", "clone", "--filter=blob:none", + "https://github.com/echasnovski/mini.nvim", mini_path + }) -vim.api.nvim_create_autocmd({"InsertCharPre"}, { - callback = function() - vim.lsp.buf.completion() + vim.cmd("packadd mini.nvim | helptags ALL") +end + +require("mini.deps").setup({ path = { package = path_package } }) + +local add, now, later = MiniDeps.add, MiniDeps.now, MiniDeps.later +now(function() + add({ + source = "neovim/nvim-lspconfig", + }) + + add({ + source = "hrsh7th/nvim-cmp", + depends = { "hrsh7th/cmp-nvim-lsp" } + }) +end) + +local cmp = require("cmp") +cmp.setup({ + snippet = { + expand = function(args) + vim.snippet.expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.confirm({ select = true }) + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + }) +}, { + { name = "buffer" }, +}); + +local lspconfig = require("lspconfig") +local capabilities = require("cmp_nvim_lsp").default_capabilities() +for server in pairs(servers) do + local config = servers[server] + config.capabilities = config.capabilities or capabilities + + lspconfig[server].setup(config) +end + +vim.keymap.set({ 'i', 's' }, '', function() + if vim.snippet.active({ direction = 1 }) then + return 'lua vim.snippet.jump(1)' + else + return '' end -}) +end, { expr = true }) -vim.api.nvim_create_autocmd({"CursorMovedI"}, { - callback = function() - vim.lsp.buf.hover() +vim.keymap.set({ 'i', 's' }, '', function() + if vim.snippet.active({ direction = 1 }) then + return 'lua vim.snippet.jump(-1)' + else + return '' end -}) +end, { expr = true })