From 1db9d4a9800aa461c52665110fd01aafb6182c56 Mon Sep 17 00:00:00 2001 From: Jannik Buhr Date: Wed, 6 Nov 2024 16:07:20 +0100 Subject: [PATCH] blink wip --- init.lua | 1 + lua/plugins/completion.lua | 85 +++++++++++++++++++++++++++++++++++++- lua/plugins/lsp.lua | 27 ++++++------ 3 files changed, 99 insertions(+), 14 deletions(-) diff --git a/init.lua b/init.lua index e1ba5a7..30a100b 100644 --- a/init.lua +++ b/init.lua @@ -20,5 +20,6 @@ require 'config.redir' -- vim.treesitter.language.add('pandoc_markdown_inline', { path = "/usr/local/lib/libtree-sitter-pandoc-markdown-inline.so" }) -- vim.treesitter.language.register('pandoc_markdown', { 'quarto', 'rmarkdown' }) +vim.treesitter.language.register("markdown", 'quarto') vim.treesitter.language.register("markdown", 'text') diff --git a/lua/plugins/completion.lua b/lua/plugins/completion.lua index a5d80f4..697ca95 100644 --- a/lua/plugins/completion.lua +++ b/lua/plugins/completion.lua @@ -7,8 +7,90 @@ return { end, }, + { -- new completion plugin + 'saghen/blink.cmp', + enabled = true, + lazy = false, -- lazy loading handled internally + -- optional: provides snippets for the snippet source + dependencies = { + { 'rafamadriz/friendly-snippets' }, + { 'saghen/blink.compat' }, + { 'jmbuhr/cmp-pandoc-references', + dev = true, + ft = {'quarto', 'markdown', 'rmarkdown'}, + config = function () + vim.api.nvim_create_autocmd('FileType', { + pattern = {"markdown", "quarto", "rmarkdown"}, + callback = function () + require('cmp-pandoc-references.lsp').start() + end + }) + end + }, + { 'hrsh7th/cmp-emoji' }, + { 'kdheepak/cmp-latex-symbols' }, + }, + + -- use a release tag to download pre-built binaries + version = 'v0.*', + -- OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust + -- build = 'cargo build --release', + -- If you use nix, you can build from source using latest nightly rust with: + -- build = 'nix run .#build-plugin', + + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + -- 'default' for mappings similar to built-in completion + -- 'super-tab' for mappings similar to vscode (tab to accept, arrow keys to navigate) + -- 'enter' for mappings similar to 'super-tab' but with 'enter' to accept + -- see the "default configuration" section below for full documentation on how to define + -- your own keymap. + keymap = { preset = 'enter' }, + + sources = { + completion = { + enabled_providers = { "lsp", "path", "snippets", "buffer", "lazydev", "references", "emoji", "symbols" }, + }, + providers = { + -- dont show LuaLS require statements when lazydev has items + lsp = { fallback_for = { "lazydev" } }, + lazydev = { name = "LazyDev", module = "lazydev.integrations.blink" }, + -- references = { + -- name = "pandoc_references", + -- module = "blink.compat.source", + -- opts = { + -- impersonate_nvim_cmp = true, + -- enable_events = true, + -- debug = true, + -- } + -- }, + emoji = { name = "emoji", module = "blink.compat.source" }, + symbols = { name = "symbols", module = "blink.compat.source" }, + }, + }, + + highlight = { + -- sets the fallback highlight groups to nvim-cmp's highlight groups + -- useful for when your theme doesn't support blink.cmp + -- will be removed in a future release, assuming themes add support + use_nvim_cmp_as_default = true, + }, + -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- adjusts spacing to ensure icons are aligned + nerd_font_variant = 'mono', + + -- experimental auto-brackets support + accept = { auto_brackets = { enabled = true } }, + + -- experimental signature help support + trigger = { signature_help = { enabled = true } }, + } + }, + { -- completion 'hrsh7th/nvim-cmp', + enabled = false, event = 'InsertEnter', dependencies = { 'hrsh7th/cmp-nvim-lsp', @@ -154,7 +236,7 @@ return { { -- gh copilot 'zbirenbaum/copilot.lua', - enabled = false, + enabled = true, config = function() require('copilot').setup { suggestion = { @@ -177,6 +259,7 @@ return { { -- LLMs "olimorris/codecompanion.nvim", + enabled = false, dependencies = { "nvim-lua/plenary.nvim", "nvim-treesitter/nvim-treesitter", diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 6ce4eee..81e3132 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -5,7 +5,7 @@ return { -- for lsp features in code cells / embedded code 'jmbuhr/otter.nvim', - dev = false, + dev = true, dependencies = { { 'neovim/nvim-lspconfig', @@ -44,16 +44,16 @@ return { }, }, { 'Bilal2453/luvit-meta', lazy = true }, -- optional `vim.uv` typings - { -- optional completion source for require statements and module annotations - 'hrsh7th/nvim-cmp', - opts = function(_, opts) - opts.sources = opts.sources or {} - table.insert(opts.sources, { - name = 'lazydev', - group_index = 0, -- set group index to 0 to skip loading LuaLS completions - }) - end, - }, + -- { -- optional completion source for require statements and module annotations + -- 'hrsh7th/nvim-cmp', + -- opts = function(_, opts) + -- opts.sources = opts.sources or {} + -- table.insert(opts.sources, { + -- name = 'lazydev', + -- group_index = 0, -- set group index to 0 to skip loading LuaLS completions + -- }) + -- end, + -- }, -- { "folke/neodev.nvim", enabled = false }, -- make sure to uninstall or disable neodev.nvim }, { 'folke/neoconf.nvim', opts = {}, enabled = false }, @@ -116,8 +116,9 @@ return { } local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) - capabilities.textDocument.completion.completionItem.snippetSupport = true + -- capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) + -- capabilities.textDocument.completion.completionItem.snippetSupport = true + capabilities = require('blink.cmp').get_lsp_capabilities(capabilities) -- also needs: -- $home/.config/marksman/config.toml :