|
| 1 | +local fn = vim.fn |
| 2 | + |
| 3 | +local install_path = fn.stdpath('data') .. '/site/pack/paqs/start/paq-nvim' |
| 4 | + |
| 5 | +if fn.empty(fn.glob(install_path)) > 0 then |
| 6 | + fn.system({'git', 'clone', '--depth=1', 'https://github.com/savq/paq-nvim.git', install_path}) |
| 7 | +end |
| 8 | + |
| 9 | +require "paq" { |
| 10 | + "savq/paq-nvim", -- Let Paq manage itself |
| 11 | + "neovim/nvim-lspconfig", -- Mind the semi-colons |
| 12 | + "hrsh7th/nvim-cmp", -- Use braces when passing options |
| 13 | + "ray-x/lsp_signature.nvim", "hrsh7th/cmp-nvim-lsp", "L3MON4D3/LuaSnip", |
| 14 | + "saadparwaiz1/cmp_luasnip", "windwp/nvim-autopairs" |
| 15 | +} |
| 16 | +vim.cmd([[colorscheme darkblue]]) |
| 17 | + |
| 18 | +local cmp = require('cmp') |
| 19 | +cmp.setup { |
| 20 | + mapping = { |
| 21 | + ["<CR>"] = cmp.mapping.confirm({select = true}), |
| 22 | + ["<C-p>"] = cmp.mapping.select_prev_item(), |
| 23 | + ["<C-n>"] = cmp.mapping.select_next_item(), |
| 24 | + ["<C-d>"] = cmp.mapping.scroll_docs(-4), |
| 25 | + ["<C-f>"] = cmp.mapping.scroll_docs(4), |
| 26 | + ["<C-e>"] = cmp.mapping.close(), |
| 27 | + ["<Tab>"] = cmp.mapping(function(fallback) |
| 28 | + if cmp.visible() then |
| 29 | + cmp.select_next_item() |
| 30 | + elseif require('luasnip').expand_or_jumpable() then |
| 31 | + require('luasnip').expand_or_jump() |
| 32 | + elseif has_words_before() then |
| 33 | + cmp.complete() |
| 34 | + else |
| 35 | + fallback() |
| 36 | + end |
| 37 | + end, {"i", "s"}), |
| 38 | + ["<S-Tab>"] = cmp.mapping(function(fallback) |
| 39 | + if cmp.visible() then |
| 40 | + cmp.select_prev_item() |
| 41 | + elseif require('luasnip').jumpable(-1) then |
| 42 | + require('luasnip').jump(-1) |
| 43 | + else |
| 44 | + fallback() |
| 45 | + end |
| 46 | + end, {"i", "s"}) |
| 47 | + }, |
| 48 | + snippet = { |
| 49 | + expand = function(args) |
| 50 | + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. |
| 51 | + end |
| 52 | + }, |
| 53 | + sources = {{name = 'nvim_lsp'}, {name = 'luasnip'}}, |
| 54 | + completion = {completeopt = 'menu,menuone,noinsert'}, |
| 55 | + experimental = {ghost_text = true} |
| 56 | +} |
| 57 | + |
| 58 | +require("luasnip").config.set_config {history = true, updateevents = "TextChanged,TextChangedI"} |
| 59 | +require("luasnip.loaders.from_vscode").load() |
| 60 | + |
| 61 | +require('nvim-autopairs').setup() |
| 62 | +local cmp_autopairs = require('nvim-autopairs.completion.cmp') |
| 63 | +local cmp = require('cmp') |
| 64 | + |
| 65 | +cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({map_char = {tex = ''}})) |
| 66 | + |
| 67 | +cmp_autopairs.lisp[#cmp_autopairs.lisp + 1] = "racket" |
| 68 | + |
| 69 | +local capabilities = vim.lsp.protocol.make_client_capabilities() |
| 70 | +capabilities.textDocument.completion.completionItem.snippetSupport = true |
| 71 | +capabilities.textDocument.completion.completionItem.resolveSupport = { |
| 72 | + properties = {'documentation', 'detail', 'additionalTextEdits'} |
| 73 | +} |
| 74 | + |
| 75 | +local sumneko_root_path = vim.fn.expand("$HOME") .. '/github/sumneko/lua-language-server' |
| 76 | +local sumneko_binary = vim.fn.expand("$HOME") .. '/github/sumneko/lua-language-server/bin/macOS/lua-language-server' |
| 77 | + |
| 78 | +local lua_cfg = { |
| 79 | + cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}, |
| 80 | + settings = { |
| 81 | + Lua = { |
| 82 | + runtime = {version = "LuaJIT", path = vim.split(package.path, ";")}, |
| 83 | + diagnostics = {enable = true} |
| 84 | + } |
| 85 | + }, |
| 86 | + capabilities = capabilities |
| 87 | + |
| 88 | +} |
| 89 | + |
| 90 | +local signature_config = { |
| 91 | + log_path = vim.fn.expand("$HOME") .. "/tmp/sig.log", |
| 92 | + debug = true, |
| 93 | + hint_enable = false, |
| 94 | + handler_opts = {border = "single"}, |
| 95 | + max_width = 80 |
| 96 | +} |
| 97 | + |
| 98 | +require"lsp_signature".setup(signature_config) |
| 99 | + |
| 100 | +require'lspconfig'.sumneko_lua.setup(lua_cfg) |
| 101 | +require'lspconfig'.gopls.setup {capabilities = capabilities} |
| 102 | +vim.cmd([[set mouse=a]]) |
0 commit comments