Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:jmbuhr/quarto-nvim-kickstarter into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbuhr committed Jan 7, 2025
2 parents 934c7fe + 1c79046 commit 65a16d5
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 57 deletions.
12 changes: 7 additions & 5 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
-- (may be outdated with newer versions of the plugins,
-- check for yourself if you're interested in using them)

require 'config.global'
require 'config.lazy'
require 'config.autocommands'
require 'config.redir'


-- vim.treesitter.language.add('pandoc_markdown', { path = "/usr/local/lib/libtree-sitter-pandoc-markdown.so" })
-- 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')

require 'config.global'
require 'config.lazy'
require 'config.autocommands'
require 'config.redir'


186 changes: 156 additions & 30 deletions lua/plugins/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,55 +14,181 @@ return {
-- optional: provides snippets for the snippet source
dependencies = {
{ 'rafamadriz/friendly-snippets' },
{ 'moyiz/blink-emoji.nvim' },
{
'saghen/blink.compat',
dev = false,
opts = { impersonate_nvim_cmp = true, enable_events = true, debug = true },
},
{
'jmbuhr/cmp-pandoc-references',
dev = true,
-- ft = { 'quarto', 'markdown', 'rmarkdown' },
},
{
"allaman/emoji.nvim",
opts = { enable_cmp_integration = true },
dev = false,
ft = { 'quarto', 'markdown', 'rmarkdown' },
},
{ 'kdheepak/cmp-latex-symbols' },
},
-- use a release tag to download pre-built binaries
-- version = 'v0.*',
build = 'cargo build --release',

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',
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
keymap = { preset = 'enter' },
sources = {
default = { "lsp", "path", "references", "snippets", "lazydev", "emoji", "latex_symbols", "codecompanion", "buffer" },
cmdline = {},
default = { "lazydev", "lsp", "path", "snippets", "buffer", "emoji" },
cmdline = {
enabled = false,
},
providers = {
lazydev = { name = "LazyDev", module = "lazydev.integrations.blink" },
references = { name = "references", module = "cmp-pandoc-references.blink" },
emoji = { name = "emoji", module = "blink.compat.source", opts = {impersonate_nvim_cmp = true} },
latex_symbols = { name = "latex_symbols", module = "blink.compat.source", opts = {impersonate_nvim_cmp = true} },
codecompanion = { name = 'CodeCompanion', module = 'codecompanion.providers.completion.blink', enabled = true },
emoji = {
module = "blink-emoji",
name = "Emoji",
score_offset = 15, -- Tune by preference
},
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
-- make lazydev completions top priority (see `:h blink.cmp`)
score_offset = 100,
},
references = {
name = "pandoc_references",
module = "blink.compat.source",
},
symbols = { name = "symbols", module = "blink.compat.source" },
},
},
appearance = {
-- 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
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'
},
completion = {
accept = { auto_brackets = { enabled = true } },
menu = {
draw = {
treesitter = {'lsp'},
columns = { { 'kind_icon' }, { 'label', 'label_description', gap = 1 }, {'source_name'} },
components = {
label_description = {
width = { max = 30 },
text = function(ctx)
-- print(vim.inspect(ctx.label_description()))
return ctx.label_description
end,
highlight = 'BlinkCmpLabelDescription',
},
documentation = {
auto_show = true,
auto_show_delay_ms = 500,
treesitter_highlighting = true,
},
menu = { auto_show = function(ctx) return ctx.mode ~= 'cmdline' end },
},
signature = { enabled = true }
},
},

{ -- completion
'hrsh7th/nvim-cmp',
enabled = false,
event = 'InsertEnter',
dependencies = {
'hrsh7th/cmp-nvim-lsp',
'jmbuhr/cmp-nvim-lsp-signature-help',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-calc',
'hrsh7th/cmp-emoji',
'saadparwaiz1/cmp_luasnip',
'f3fora/cmp-spell',
'ray-x/cmp-treesitter',
'kdheepak/cmp-latex-symbols',
'jmbuhr/cmp-pandoc-references',
'L3MON4D3/LuaSnip',
'rafamadriz/friendly-snippets',
'onsails/lspkind-nvim',
},
config = function()
local cmp = require 'cmp'
local luasnip = require 'luasnip'
local lspkind = require 'lspkind'

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 {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
completion = { completeopt = 'menu,menuone,noinsert' },
mapping = {
['<C-f>'] = cmp.mapping.scroll_docs(-4),
['<C-d>'] = cmp.mapping.scroll_docs(4),

['<C-n>'] = cmp.mapping(function(fallback)
if luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
fallback()
end
end, { 'i', 's' }),
['<C-p>'] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
['<C-e>'] = cmp.mapping.abort(),
['<c-y>'] = cmp.mapping.confirm {
select = true,
},
['<CR>'] = cmp.mapping.confirm {
select = true,
},

['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { 'i', 's' }),

['<C-l>'] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
end
end, { 'i', 's' }),
['<C-h>'] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
end
end, { 'i', 's' }),
},
autocomplete = false,

---@diagnostic disable-next-line: missing-fields
formatting = {
format = lspkind.cmp_format {
mode = 'symbol',
menu = {
nvim_lsp = '[LSP]',
nvim_lsp_signature_help = '[sig]',
luasnip = '[snip]',
buffer = '[buf]',
path = '[path]',
spell = '[spell]',
pandoc_references = '[ref]',
tags = '[tag]',
treesitter = '[TS]',
calc = '[calc]',
latex_symbols = '[tex]',
emoji = '[emoji]',
},
},
},
Expand Down
10 changes: 5 additions & 5 deletions lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@ return {
-- Add additional languages here.
-- See `:h lspconfig-all` for the configuration.
-- Like e.g. Haskell:
lspconfig.hls.setup {
capabilities = capabilities,
flags = lsp_flags,
filetypes = { 'haskell', 'lhaskell', 'cabal' },
}
-- lspconfig.hls.setup {
-- capabilities = capabilities,
-- flags = lsp_flags,
-- filetypes = { 'haskell', 'lhaskell', 'cabal' },
-- }

lspconfig.clangd.setup {
capabilities = capabilities,
Expand Down
42 changes: 29 additions & 13 deletions lua/plugins/quarto.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,39 @@ return {
{
'benlubas/molten-nvim',
dev = false,
enabled = false,
enabled = true,
version = "^1.0.0", -- use version <2.0.0 to avoid breaking changes
build = ':UpdateRemotePlugins',
init = function()
vim.g.molten_image_provider = 'image.nvim'
vim.g.molten_output_win_max_height = 20
-- vim.g.molten_output_win_max_height = 20
vim.g.molten_auto_open_output = true
vim.g.molten_auto_open_html_in_browser = true
vim.g.molten_tick_rate = 200
end,
config = function()
local init = function()
local quarto_cfg = require'quarto.config'.config
quarto_cfg.codeRunner.default_method = "molten"
vim.cmd[[MoltenInit]]
end
local deinit = function()
local quarto_cfg = require'quarto.config'.config
quarto_cfg.codeRunner.default_method = "slime"
vim.cmd[[MoltenDeinit]]
end
vim.keymap.set("n", "<localleader>mi", init,
{ silent = true, desc = "Initialize molten" })
vim.keymap.set("n", "<localleader>md", deinit,
{ silent = true, desc = "Stop molten" })
vim.keymap.set("n", "<localleader>mp", ":MoltenImagePopup<CR>",
{ silent = true, desc = "molten image popup" })
vim.keymap.set("n", "<localleader>mb", ":MoltenOpenInBrowser<CR>",
{ silent = true, desc = "molten open in browser" })
vim.keymap.set("n", "<localleader>mh", ":MoltenHideOutput<CR>",
{ silent = true, desc = "hide output" })
vim.keymap.set("n", "<localleader>ms", ":noautocmd MoltenEnterOutput<CR>",
{ silent = true, desc = "show/enter output" })
end,
keys = {
{ '<leader>mi', ':MoltenInit<cr>', desc = '[m]olten [i]nit' },
{ '<leader>md', ':MoltenDeinit<cr>', desc = '[m]olten [d]einit' },
{
'<leader>mv',
':<C-u>MoltenEvaluateVisual<cr>',
mode = 'v',
desc = 'molten eval visual',
},
{ '<leader>mr', ':MoltenReevaluateCell<cr>', desc = 'molten re-eval cell' },
},
},
}
8 changes: 4 additions & 4 deletions lua/plugins/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,10 @@ return {
window_overlap_clear_enabled = true,
tmux_show_only_in_active_window = true,
window_overlap_clear_ft_ignore = { 'cmp_menu', 'cmp_docs', 'scrollview', 'scrollview_sign' },
max_width = nil,
max_height = nil,
max_width_window_percentage = nil,
max_height_window_percentage = 30,
max_width = 100,
max_height = 14,
max_height_window_percentage = math.huge,
max_width_window_percentage = math.huge,
kitty_method = 'normal',
}

Expand Down

0 comments on commit 65a16d5

Please sign in to comment.