Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbuhr committed Jun 29, 2024
2 parents f6d8afe + 03492ee commit 34f59fe
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 44 deletions.
13 changes: 8 additions & 5 deletions lua/config/keymap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,11 @@ wk.register({
f = { '<cmd>Telescope find_files<cr>', '[f]iles' },
h = { '<cmd>Telescope help_tags<cr>', '[h]elp' },
k = { '<cmd>Telescope keymaps<cr>', '[k]eymaps' },
r = { '<cmd>Telescope lsp_references<cr>', '[r]eferences' },
g = { '<cmd>Telescope live_grep<cr>', '[g]rep' },
b = { '<cmd>Telescope current_buffer_fuzzy_find<cr>', '[b]uffer fuzzy find' },
m = { '<cmd>Telescope marks<cr>', '[m]arks' },
M = { '<cmd>Telescope man_pages<cr>', '[M]an pages' },
c = { '<cmd>Telescope git_commits<cr>', 'git [c]ommits' },
s = { '<cmd>Telescope lsp_document_symbols<cr>', 'document [s]ymbols' },
['<space>'] = { '<cmd>Telescope buffers<cr>', '[ ] buffers' },
d = { '<cmd>Telescope buffers<cr>', '[d] buffers' },
q = { '<cmd>Telescope quickfix<cr>', '[q]uickfix' },
Expand Down Expand Up @@ -347,21 +345,26 @@ wk.register({
},
l = {
name = '[l]anguage/lsp',
r = { '<cmd>Telescope lsp_references<cr>', '[r]eferences' },
r = { vim.lsp.buf.references, '[r]eferences' },
R = { '[R]ename' },
D = { vim.lsp.buf.type_definition, 'type [D]efinition' },
a = { vim.lsp.buf.code_action, 'code [a]ction' },
e = { vim.diagnostic.open_float, 'diagnostics (show hover [e]rror)' },
d = {
name = '[d]iagnostics',
d = { vim.diagnostic.disable, '[d]isable' },
d = {
function()
vim.diagnostic.enable(false)
end,
'[d]isable',
},
e = { vim.diagnostic.enable, '[e]nable' },
},
g = { ':Neogen<cr>', 'neo[g]en docstring' },
},
o = {
name = '[o]tter & c[o]de',
a = { require('otter').dev_setup, 'otter [a]ctivate' },
a = { require('otter').activate, 'otter [a]ctivate' },
d = { require('otter').deactivate, 'otter [d]eactivate' },
c = { 'O# %%<cr>', 'magic [c]omment code chunk # %%' },
r = { insert_r_chunk, '[r] code chunk' },
Expand Down
11 changes: 11 additions & 0 deletions lua/plugins/colorthemes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ return {
lazy = false,
priority = 1000,
config = function()
require('kanagawa').setup {
colors = {
theme = {
all = {
ui = {
bg_gutter = 'none',
},
},
},
},
}
vim.cmd.colorscheme 'kanagawa'
vim.api.nvim_set_hl(0, 'TermCursor', { fg = '#A6E3A1', bg = '#A6E3A1' })
end,
Expand Down
4 changes: 2 additions & 2 deletions lua/plugins/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ return {
},
},
sources = {
{ name = 'otter' }, -- for code chunks in quarto
-- { name = 'otter' }, -- for code chunks in quarto
{ name = 'path' },
{ name = 'nvim_lsp' },
{ name = 'nvim_lsp_signature_help' },
Expand Down Expand Up @@ -155,7 +155,7 @@ return {

{ -- gh copilot
'zbirenbaum/copilot.lua',
enabled = false,
enabled = true,
config = function()
require('copilot').setup {
suggestion = {
Expand Down
2 changes: 2 additions & 0 deletions lua/plugins/editing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ return {
formatters_by_ft = {
lua = { 'mystylua' },
python = { 'isort', 'black' },
quarto = { 'injected' },
},
formatters = {
mystylua = {
Expand Down Expand Up @@ -88,6 +89,7 @@ return {

{
'chrishrb/gx.nvim',
enabled = false,
keys = { { 'gx', '<cmd>Browse<cr>', mode = { 'n', 'x' } } },
cmd = { 'Browse' },
init = function()
Expand Down
81 changes: 56 additions & 25 deletions lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
return {

{

-- for lsp features in code cells / embedded code
Expand All @@ -8,21 +9,9 @@ return {
{
'neovim/nvim-lspconfig',
'nvim-treesitter/nvim-treesitter',
'hrsh7th/nvim-cmp',
},
},
opts = {
lsp = {
hover = {
border = require('misc.style').border,
},
},
buffers = {
set_filetype = true,
write_to_disk = false,
},
handle_leading_whitespace = true,
},
opts = {},
},

{
Expand All @@ -37,7 +26,31 @@ return {
enabled = false,
opts = {},
},
{ 'folke/neodev.nvim', opts = {}, enabled = true },
{
{
'folke/lazydev.nvim',
ft = 'lua', -- only load on lua files
opts = {
library = {
-- See the configuration section for more details
-- Load luvit types when the `vim.uv` word is found
{ path = 'luvit-meta/library', words = { 'vim%.uv' } },
},
},
},
{ '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,
},
-- { "folke/neodev.nvim", enabled = false }, -- make sure to uninstall or disable neodev.nvim
},
{ 'folke/neoconf.nvim', opts = {}, enabled = false },
},
config = function()
Expand All @@ -62,29 +75,32 @@ return {
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
callback = function(event)
local telescope = require 'telescope.builtin'
local function map(keys, func, desc)
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end
local function vmap(keys, func, desc)
vim.keymap.set('v', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end

local client = vim.lsp.get_client_by_id(event.data.client_id)
assert(client, 'LSP client not found')

---@diagnostic disable-next-line: inject-field
client.server_capabilities.document_formatting = true

map('gS', telescope.lsp_document_symbols, '[g]o so [S]ymbols')
map('gD', telescope.lsp_type_definitions, '[g]o to type [D]efinition')
map('gd', telescope.lsp_definitions, '[g]o to [d]efinition')
map('K', '<cmd>lua vim.lsp.buf.hover()<CR>', '[K] hover documentation')
map('gh', '<cmd>lua vim.lsp.buf.signature_help()<CR>', '[g]o to signature [h]elp')
map('gI', telescope.lsp_implementations, '[g]o to [I]mplementation')
map('gr', telescope.lsp_references, '[g]o to [r]eferences')
map('gS', vim.lsp.buf.document_symbol, '[g]o so [S]ymbols')
map('gD', vim.lsp.buf.type_definition, '[g]o to type [D]efinition')
map('gd', vim.lsp.buf.definition, '[g]o to [d]efinition')
map('K', vim.lsp.buf.hover, '[K] hover documentation')
map('gh', vim.lsp.buf.signature_help, '[g]o to signature [h]elp')
map('gI', vim.lsp.buf.implementation, '[g]o to [I]mplementation')
map('gr', vim.lsp.buf.references, '[g]o to [r]eferences')
map('[d', vim.diagnostic.goto_prev, 'previous [d]iagnostic ')
map(']d', vim.diagnostic.goto_next, 'next [d]iagnostic ')
map('<leader>ll', vim.lsp.codelens.run, '[l]ens run')
map('<leader>lR', vim.lsp.buf.rename, '[l]sp [R]ename')
map('<leader>lf', vim.lsp.buf.format, '[l]sp [f]ormat')
vmap('<leader>lf', vim.lsp.buf.format, '[l]sp [f]ormat')
map('<leader>lq', vim.diagnostic.setqflist, '[l]sp diagnostic [q]uickfix')
end,
})
Expand All @@ -93,8 +109,11 @@ return {
allow_incremental_sync = true,
debounce_text_changes = 150,
}

vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = require('misc.style').border })
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = require('misc.style').border })
-- TODO: handle this
-- vim.lsp.handlers['textDocument/references'] = telescope_builtin.lsp_references

local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())
Expand Down Expand Up @@ -150,6 +169,11 @@ return {
},
}

lspconfig.jsonls.setup {
capabilities = capabilities,
flags = lsp_flags,
}

lspconfig.dotls.setup {
capabilities = capabilities,
flags = lsp_flags,
Expand Down Expand Up @@ -196,16 +220,18 @@ return {
},
runtime = {
version = 'LuaJIT',
plugin = lua_plugin_paths,
-- plugin = lua_plugin_paths,
},
diagnostics = {
globals = { 'vim', 'quarto', 'pandoc', 'io', 'string', 'print', 'require', 'table' },
disable = { 'trailing-space' },
},
workspace = {
library = lua_library_files,
-- library = lua_library_files,
checkThirdParty = false,
},
doc = {
privateName = { '^_' },
},
telemetry = {
enable = false,
},
Expand Down Expand Up @@ -248,6 +274,11 @@ return {
-- }
-- }

-- lspconfig.ruff_lsp.setup {
-- capabilities = capabilities,
-- flags = lsp_flags,
-- }

-- See https://github.com/neovim/neovim/issues/23291
-- disable lsp watcher.
-- Too lags on linux for python projects
Expand Down
2 changes: 1 addition & 1 deletion lua/plugins/quarto.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ return {
dev = false,
opts = {
lspFeatures = {
languages = { 'r', 'python', 'julia', 'bash', 'lua', 'html', 'dot', 'javascript', 'typescript', 'ojs' },
languages = { 'r', 'python', 'julia', 'bash', 'lua', 'html', 'dot', 'javascript', 'typescript', 'ojs', 'lua' },
},
codeRunner = {
enabled = true,
Expand Down
8 changes: 7 additions & 1 deletion lua/plugins/treesitter.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
return {
{
'nvim-treesitter/nvim-treesitter',
dev = false,
dependencies = {
{ 'nvim-treesitter/nvim-treesitter-textobjects' },
-- {
-- -- currently broken for R
-- 'nvim-treesitter/nvim-treesitter-textobjects',
-- dev = false,
-- enabled = false,
-- },
},
run = ':TSUpdate',
config = function()
Expand Down
11 changes: 1 addition & 10 deletions lua/plugins/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ return {
vimgrep_arguments = vimgrep_arguments,
file_ignore_patterns = {
'node_modules',
'%_files/',
'%_cache',
'.git/',
'site_libs',
Expand Down Expand Up @@ -334,15 +333,6 @@ return {
enabled = true,
dev = false,
ft = { 'markdown', 'quarto', 'vimwiki' },
dependencies = {
{
'vhyrro/luarocks.nvim',
priority = 1001, -- this plugin needs to run before anything else
opts = {
rocks = { 'magick' },
},
},
},
config = function()
-- Requirements
-- https://github.com/3rd/image.nvim?tab=readme-ov-file#requirements
Expand All @@ -351,6 +341,7 @@ return {
-- sudo apt install imagemagick
-- sudo apt install libmagickwand-dev
-- sudo apt install liblua5.1-0-dev
-- sudo apt install lua5.1
-- sudo apt installl luajit

local image = require 'image'
Expand Down
12 changes: 12 additions & 0 deletions snips/snippets/quarto.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
{
"ipython_interactive": {
"prefix": ["ipyinteractive"],
"body": [
"```{python}",
"from IPython.core.getipython import get_ipython",
"ip = get_ipython()",
"interactive = False",
"if ip is not None and 'interactiveshell.TerminalInteractiveShell' in str(ip):",
" interactive = True",
"```"
]
},
"iframe": {
"prefix": ["iframe"],
"body": [
Expand Down

0 comments on commit 34f59fe

Please sign in to comment.