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
2 changes: 1 addition & 1 deletion after/lsp/marksman.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---@type vim.lsp.Config
return {
cmd = { 'marksman', 'server' },
filetypes = { 'markdown', 'markdown.mdx' },
filetypes = { 'markdown' },
root_markers = { '.marksman.toml', '.git' },
}
96 changes: 0 additions & 96 deletions lua/config/autocommands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,99 +187,3 @@ vim.api.nvim_create_autocmd('FocusGained', {
end,
desc = 'Close non-existing buffers',
})

local lsp_group = vim.api.nvim_create_augroup('my.lsp', { clear = true })

vim.api.nvim_create_autocmd('LspAttach', {
group = lsp_group,
desc = 'LSP keymaps & features',
callback = function(ev)
local client = assert(vim.lsp.get_client_by_id(ev.data.client_id))
local bufnr = ev.buf

local map = function(mode, lhs, rhs, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, lhs, rhs, opts)
end

-- diagnostics
map('n', '<leader>D', vim.diagnostic.open_float)

-- completion
vim.lsp.completion.enable(true, client.id, bufnr, { autotrigger = true })

-- navigation
if client:supports_method('textDocument/definition') then
map('n', 'gd', vim.lsp.buf.definition)
end

if client:supports_method('textDocument/declaration') then
map('n', 'gD', vim.lsp.buf.declaration)
end

if client:supports_method('textDocument/typeDefinition') then
map('n', '<leader>gt', vim.lsp.buf.type_definition)
end

if client:supports_method('textDocument/implementation') then
map('n', 'gri', vim.lsp.buf.implementation)
end

if client:supports_method('callHierarchy/incomingCalls') then
map('n', 'grI', vim.lsp.buf.incoming_calls)
end

-- editing
if client:supports_method('textDocument/rename') then
map('n', '<leader>R', vim.lsp.buf.rename)
end

if client:supports_method('textDocument/onTypeFormatting') then
vim.lsp.on_type_formatting.enable()
end

map('i', '<M-s>', vim.lsp.buf.signature_help)

-- UI extras
if client:supports_method('textDocument/documentSymbol') then
require('nvim-navic').attach(client, bufnr)
end

if client:supports_method('textDocument/documentColor') then
vim.lsp.document_color.enable(true, bufnr)
end

if client:supports_method('textDocument/inlayHint') and vim.g.lsp_inlay_hints then
vim.lsp.inlay_hint.enable(true)
end

if client:supports_method('textDocument/inlineCompletion') then
vim.lsp.inline_completion.enable(true, { bufnr = bufnr })
map('i', '<C-F>', vim.lsp.inline_completion.get, { desc = 'Accept inline completion' })
map('i', '<C-G>', vim.lsp.inline_completion.select, { desc = 'Cycle inline completion' })
end

if client:supports_method('textDocument/documentHighlight') then
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = bufnr,
group = lsp_group,
callback = vim.lsp.buf.document_highlight,
})

vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
buffer = bufnr,
group = lsp_group,
callback = vim.lsp.buf.clear_references,
})
end
end,
})

vim.api.nvim_create_autocmd({ 'LspAttach', 'LspDetach', 'DiagnosticChanged' }, {
group = vim.api.nvim_create_augroup('StatuslineUpdate', { clear = true }),
desc = 'Update statusline/winbar',
callback = vim.schedule_wrap(function()
vim.cmd.redrawstatus()
end),
})
4 changes: 3 additions & 1 deletion lua/config/icons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ return {
},
spinner = {
dot = { '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏' },
circle = { '  ', '  ', '  ', '  ', '  ', '  ' },
arc = { '◜', '◠', '◝', '◞', '◡', '◟' },
circle = { '◐', '◓', '◑', '◒', '◐', '◓', '◑', '◒' },
quarter = { '◴', '◷', '◶', '◵' },
},
todolist = {
todo = '  ',
Expand Down
96 changes: 96 additions & 0 deletions lua/config/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,99 @@ vim.diagnostic.config({
float = true,
jump = { on_jump = vim.diagnostic.open_float },
})

local lsp_group = vim.api.nvim_create_augroup('my.lsp', { clear = true })

vim.api.nvim_create_autocmd('LspAttach', {
group = lsp_group,
desc = 'LSP keymaps & features',
callback = function(ev)
local client = assert(vim.lsp.get_client_by_id(ev.data.client_id))
local bufnr = ev.buf

local map = function(mode, lhs, rhs, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, lhs, rhs, opts)
end

-- diagnostics
map('n', '<leader>D', vim.diagnostic.open_float)

-- completion
vim.lsp.completion.enable(true, client.id, bufnr)

-- navigation
if client:supports_method('textDocument/definition') then
map('n', 'gd', vim.lsp.buf.definition)
end

if client:supports_method('textDocument/declaration') then
map('n', 'gD', vim.lsp.buf.declaration)
end

if client:supports_method('textDocument/typeDefinition') then
map('n', '<leader>gt', vim.lsp.buf.type_definition)
end

if client:supports_method('textDocument/implementation') then
map('n', 'gri', vim.lsp.buf.implementation)
end

if client:supports_method('callHierarchy/incomingCalls') then
map('n', 'grI', vim.lsp.buf.incoming_calls)
end

-- editing
if client:supports_method('textDocument/rename') then
map('n', '<leader>R', vim.lsp.buf.rename)
end

if client:supports_method('textDocument/onTypeFormatting') then
vim.lsp.on_type_formatting.enable()
end

map('i', '<M-s>', vim.lsp.buf.signature_help)

-- -- UI extras
-- if client:supports_method('textDocument/documentSymbol') then
-- require('nvim-navic').attach(client, bufnr)
-- end

if client:supports_method('textDocument/documentColor') then
vim.lsp.document_color.enable(true, bufnr)
end

if client:supports_method('textDocument/inlayHint') and vim.g.lsp_inlay_hints then
vim.lsp.inlay_hint.enable(true)
end

if client:supports_method('textDocument/inlineCompletion') then
vim.lsp.inline_completion.enable(true, { bufnr = bufnr })
map('i', '<C-F>', vim.lsp.inline_completion.get, { desc = 'Accept inline completion' })
map('i', '<C-G>', vim.lsp.inline_completion.select, { desc = 'Cycle inline completion' })
end

if client:supports_method('textDocument/documentHighlight') then
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = bufnr,
group = lsp_group,
callback = vim.lsp.buf.document_highlight,
})

vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
buffer = bufnr,
group = lsp_group,
callback = vim.lsp.buf.clear_references,
})
end
end,
})

vim.api.nvim_create_autocmd({ 'LspAttach', 'LspDetach', 'DiagnosticChanged' }, {
group = vim.api.nvim_create_augroup('StatuslineUpdate', { clear = true }),
desc = 'Update statusline/winbar',
callback = vim.schedule_wrap(function()
vim.cmd.redrawstatus()
end),
})
5 changes: 3 additions & 2 deletions lua/plugins/foldtext.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
---@type LazyPluginSpec
return {
'OXY2DEV/foldtext.nvim',
lazy = false,
---@module 'foldtext'
---@type foldtext.config
opts = {
ignore_filetypes = {
'snacks_dashboard',
},
ignore_buftypes = {},
ignore_buftypes = {
'nofile',
},
styles = {
default = {
---|fS "config: Default configuration"
Expand Down
2 changes: 1 addition & 1 deletion lua/plugins/lualine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ return {
'lsp_status',
icon = '󰒋 ',
symbols = {
spinner = { '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏' },
spinner = require('config.icons').spinner.circle,
done = '✓',
separator = ' ',
},
Expand Down
4 changes: 2 additions & 2 deletions lua/plugins/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ return {
dependencies = {
{
'nvim-treesitter/nvim-treesitter-context',
lazy = false,
lazy = true,
opts = {
max_lines = 4,
multiline_threshold = 2,
Expand All @@ -24,7 +24,7 @@ return {
{
'nvim-treesitter/nvim-treesitter-textobjects',
branch = 'main',
lazy = false,
lazy = true,
init = function()
-- Disable entire built-in ftplugin mappings to avoid conflicts.
-- See https://github.com/neovim/neovim/tree/master/runtime/ftplugin for built-in ftplugins.
Expand Down
4 changes: 4 additions & 0 deletions queries/lua/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
;; extends

((identifier) @namespace.builtin
(#eq? @namespace.builtin "vim"))