Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions nvim/ftplugin/quarto.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
-- Copied from:
-- https://github.com/jmbuhr/quarto-nvim-kickstarter/blob/main/ftplugin/quarto.lua

local api = vim.api
local ts = vim.treesitter

vim.b.slime_cell_delimiter = '```'
vim.b['quarto_is_r_mode'] = nil
vim.b['reticulate_running'] = false

-- wrap text, but by word no character
-- indent the wrappped line
vim.wo.wrap = true
vim.wo.linebreak = true
vim.wo.breakindent = true
vim.wo.showbreak = '|'

-- don't run vim ftplugin on top
vim.api.nvim_buf_set_var(0, 'did_ftplugin', true)

-- markdown vs. quarto hacks
local ns = vim.api.nvim_create_namespace 'QuartoHighlight'
vim.api.nvim_set_hl(ns, '@markup.strikethrough', { strikethrough = false })
vim.api.nvim_set_hl(ns, '@markup.doublestrikethrough', { strikethrough = true })
vim.api.nvim_win_set_hl_ns(0, ns)

-- ts based code chunk highlighting uses a change
-- only availabl in nvim >= 0.10
if vim.fn.has 'nvim-0.10.0' == 0 then
return
end

-- highlight code cells similar to
-- 'lukas-reineke/headlines.nvim'
-- (disabled in lua/plugins/ui.lua)
local buf = api.nvim_get_current_buf()

local parsername = 'markdown'
local parser = ts.get_parser(buf, parsername)
local tsquery = '(fenced_code_block)@codecell'

-- vim.api.nvim_set_hl(0, '@markup.codecell', { bg = '#000055' })
vim.api.nvim_set_hl(0, '@markup.codecell', {
link = 'CursorLine',
})

local function clear_all()
local all = api.nvim_buf_get_extmarks(buf, ns, 0, -1, {})
for _, mark in ipairs(all) do
vim.api.nvim_buf_del_extmark(buf, ns, mark[1])
end
end

local function highlight_range(from, to)
for i = from, to do
vim.api.nvim_buf_set_extmark(buf, ns, i, 0, {
hl_eol = true,
line_hl_group = '@markup.codecell',
})
end
end

local function highlight_cells()
clear_all()

local query = ts.query.parse(parsername, tsquery)
local tree = parser:parse()
local root = tree[1]:root()
for _, match, _ in query:iter_matches(root, buf, 0, -1, { all = true }) do
for _, nodes in pairs(match) do
for _, node in ipairs(nodes) do
local start_line, _, end_line, _ = node:range()
pcall(highlight_range, start_line, end_line - 1)
end
end
end
end

highlight_cells()

vim.api.nvim_create_autocmd({ 'ModeChanged', 'BufWrite' }, {
group = vim.api.nvim_create_augroup('QuartoCellHighlight', { clear = true }),
buffer = buf,
callback = highlight_cells,
})
22 changes: 2 additions & 20 deletions nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ vim.keymap.set('n', '<leader>f', '<cmd>nohlsearch<CR>')
-- Diagnostic keymaps
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })

local wiki_path = vim.fn.expand('~/Dropbox/wiki/zettel')
local wiki_path = vim.fn.expand '~/Dropbox/wiki/zettel'
if vim.fn.isdirectory(wiki_path) == 1 then
vim.g.wiki_root = wiki_path
end
Expand All @@ -110,11 +110,6 @@ vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper win
-- Faster Esc
vim.keymap.set('i', 'jj', '<ESC>', { noremap = true })

-- Double leader writes the file
vim.keymap.set('n', '<leader><leader>', function()
vim.cmd 'write'
end, { noremap = true })

-- Prevent from entering Ex mode
vim.keymap.set('n', 'Q', '<nop>', { noremap = true })

Expand Down Expand Up @@ -163,18 +158,6 @@ require('lazy').setup({

{ 'catppuccin/nvim', name = 'catppuccin', priority = 1000 },

{
'jose-elias-alvarez/null-ls.nvim',
dependencies = { 'nvim-lua/plenary.nvim' },
config = function()
local null_ls = require 'null-ls'

null_ls.setup {
sources = {},
}
end,
},

-- NOTE: Plugins can also be added by using a table,
-- with the first argument being the link and the following
-- keys can be used to configure plugin behavior/loading/etc.
Expand Down Expand Up @@ -446,7 +429,7 @@ require('lazy').setup({
local servers = {
-- clangd = {},
-- gopls = {},
-- pyright = {},
pyright = {},
-- rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
Expand Down Expand Up @@ -706,7 +689,6 @@ require('lazy').setup({
require 'kickstart.plugins.debug',
require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree',
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps

-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
Expand Down
34 changes: 34 additions & 0 deletions nvim/lua/custom/plugins/codecompanion.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
return {
'olimorris/codecompanion.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-treesitter/nvim-treesitter',
},
config = function()
require('codecompanion').setup {
adapters = {
qwern = function()
return require('codecompanion.adapters').extend('ollama', {
name = 'qwern',
schema = {
model = {
default = 'qwen2.5-coder:14b',
},
},
})
end,
},
strategies = {
chat = {
adapter = 'qwern',
},
inline = {
adapter = 'qwern',
},
agent = {
adapter = 'qwern',
},
},
}
end,
}
33 changes: 30 additions & 3 deletions nvim/lua/custom/plugins/conform.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,39 @@ return {
}
end,
formatters_by_ft = {
javascript = { 'prettierd' },
lua = { 'stylua' },
yaml = { 'prettierd' },
sql = { 'sqlfmt' },
markdown = { 'prettierd' },
python = { 'ruff_format', 'ruff_fix', 'ruff_organize_imports' },
javascript = { 'prettierd' },
quarto = { 'injected' },
sql = { 'sqlfmt' },
yaml = { 'prettierd' },
},
},
-- See:
-- https://github.com/jmbuhr/quarto-nvim-kickstarter/blob/382b050e13eada7180ad048842386be37e820660/lua/plugins/editing.lua#L29-L81
config = function()
require('conform').formatters.injected = {
-- Set the options field
options = {
-- Set to true to ignore errors
ignore_errors = false,
-- Map of treesitter language to file extension
-- A temporary file name with this extension will be generated during formatting
-- because some formatters care about the filename.
lang_to_ext = {
bash = 'sh',
javascript = 'js',
latex = 'tex',
markdown = 'md',
python = 'py',
r = 'r',
typescript = 'ts',
},
-- Map of treesitter language to formatters to use
-- (defaults to the value from formatters_by_ft)
lang_to_formatters = {},
},
}
end,
}
22 changes: 22 additions & 0 deletions nvim/lua/custom/plugins/neo-tree.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
return {
'nvim-neo-tree/neo-tree.nvim',
version = '*',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons',
'MunifTanjim/nui.nvim',
},
cmd = 'Neotree',
keys = {
{ '<leader>e', '<Cmd>Neotree reveal<CR>', desc = 'Open N[e]otree', silent = true },
},
opts = {
filesystem = {
window = {
mappings = {
['<leader>e'] = 'close_window',
},
},
},
},
}
9 changes: 9 additions & 0 deletions nvim/lua/custom/plugins/quarto.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
return {
'quarto-dev/quarto-nvim',
ft = { 'quarto' },
dev = false,
opts = {},
dependencies = {
'jmbuhr/otter.nvim',
},
}
25 changes: 0 additions & 25 deletions nvim/lua/kickstart/plugins/neo-tree.lua

This file was deleted.

Loading