Skip to content

Commit

Permalink
feat: Apply the kickstart 0.10 changes in the nvim-lua#936 PR since m…
Browse files Browse the repository at this point in the history
…erging has slowed down
  • Loading branch information
MarinJuricev committed Jun 15, 2024
1 parent 8698fca commit 12807f4
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 101 deletions.
2 changes: 1 addition & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ vim.g.maplocalleader = ' '
-- [[ Install `lazy.nvim` plugin manager ]]
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
if not vim.uv.fs_stat(lazypath) then
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
end ---@diagnostic disable-next-line: undefined-field
Expand Down
1 change: 0 additions & 1 deletion lua/core/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = tr
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })

-- Diagnostic keymaps
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })

-- [[ Highlight on yank ]]
Expand Down
5 changes: 5 additions & 0 deletions lua/plugins/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ return { -- Autocompletion
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
},
sources = {
{
name = 'lazydev',
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
group_index = 0,
},
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
Expand Down
3 changes: 2 additions & 1 deletion lua/plugins/conform.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
return { -- Autoformat
'stevearc/conform.nvim',
event = { 'BufReadPre', 'BufNewFile' },
event = { 'BufReadPre' },
cmd = { 'ConformInfo ' },
keys = {
{
'<leader>fc',
Expand Down
187 changes: 98 additions & 89 deletions lua/plugins/debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,92 +5,101 @@
-- Primarily focused on configuring the debugger for Go, but can
-- be extended to other languages as well. That's why it's called
-- kickstart.nvim and not kitchen-sink.nvim ;)
return {}
-- return {
-- -- NOTE: Yes, you can install new plugins here!
-- 'mfussenegger/nvim-dap',
-- -- NOTE: And you can specify dependencies as well
-- dependencies = {
-- -- Creates a beautiful debugger UI
-- 'rcarriga/nvim-dap-ui',
--
-- -- Required dependency for nvim-dap-ui
-- 'nvim-neotest/nvim-nio',
--
-- -- Installs the debug adapters for you
-- 'williamboman/mason.nvim',
-- 'jay-babu/mason-nvim-dap.nvim',
--
-- -- Add your own debuggers here
-- 'leoluz/nvim-dap-go',
-- },
-- config = function()
-- local dap = require 'dap'
-- local dapui = require 'dapui'
--
-- require('mason-nvim-dap').setup {
-- -- Makes a best effort to setup the various debuggers with
-- -- reasonable debug configurations
-- automatic_installation = true,
--
-- -- You can provide additional configuration to the handlers,
-- -- see mason-nvim-dap README for more information
-- handlers = {},
--
-- -- You'll need to check that you have the required things installed
-- -- online, please don't ask me how to install them :)
-- ensure_installed = {
-- -- Update this to ensure that you have the debuggers for the langs you want
-- 'delve',
-- },
-- }
--
-- -- Basic debugging keymaps, feel free to change to your liking!
-- vim.keymap.set('n', '<F5>', dap.continue, { desc = 'Debug: Start/Continue' })
-- vim.keymap.set('n', '<F1>', dap.step_into, { desc = 'Debug: Step Into' })
-- vim.keymap.set('n', '<F2>', dap.step_over, { desc = 'Debug: Step Over' })
-- vim.keymap.set('n', '<F3>', dap.step_out, { desc = 'Debug: Step Out' })
-- vim.keymap.set('n', '<leader>b', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' })
-- vim.keymap.set('n', '<leader>B', function()
-- dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
-- end, { desc = 'Debug: Set Breakpoint' })
--
-- -- Dap UI setup
-- -- For more information, see |:help nvim-dap-ui|
-- dapui.setup {
-- -- Set icons to characters that are more likely to work in every terminal.
-- -- Feel free to remove or use ones that you like more! :)
-- -- Don't feel like these are good choices.
-- icons = { expanded = '▾', collapsed = '▸', current_frame = '*' },
-- controls = {
-- icons = {
-- pause = '⏸',
-- play = '▶',
-- step_into = '⏎',
-- step_over = '⏭',
-- step_out = '⏮',
-- step_back = 'b',
-- run_last = '▶▶',
-- terminate = '⏹',
-- disconnect = '⏏',
-- },
-- },
-- }
--
-- -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
-- vim.keymap.set('n', '<F7>', dapui.toggle, { desc = 'Debug: See last session result.' })
--
-- dap.listeners.after.event_initialized['dapui_config'] = dapui.open
-- dap.listeners.before.event_terminated['dapui_config'] = dapui.close
-- dap.listeners.before.event_exited['dapui_config'] = dapui.close
--
-- -- Install golang specific config
-- require('dap-go').setup {
-- delve = {
-- -- On Windows delve must be run attached or it crashes.
-- -- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring
-- detached = vim.fn.has 'win32' == 0,
-- },
-- }
-- end,
-- }

return {
-- NOTE: Yes, you can install new plugins here!
'mfussenegger/nvim-dap',
-- NOTE: And you can specify dependencies as well
dependencies = {
-- Creates a beautiful debugger UI
'rcarriga/nvim-dap-ui',

-- Required dependency for nvim-dap-ui
'nvim-neotest/nvim-nio',

-- Installs the debug adapters for you
'williamboman/mason.nvim',
'jay-babu/mason-nvim-dap.nvim',

-- Add your own debuggers here
'leoluz/nvim-dap-go',
},
keys = function(_, keys)
local dap = require 'dap'
local dapui = require 'dapui'
return {
-- Basic debugging keymaps, feel free to change to your liking!
{ '<F5>', dap.continue, desc = 'Debug: Start/Continue' },
{ '<F1>', dap.step_into, desc = 'Debug: Step Into' },
{ '<F2>', dap.step_over, desc = 'Debug: Step Over' },
{ '<F3>', dap.step_out, desc = 'Debug: Step Out' },
{ '<leader>b', dap.toggle_breakpoint, desc = 'Debug: Toggle Breakpoint' },
{
'<leader>B',
function()
dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
end,
desc = 'Debug: Set Breakpoint',
},
-- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
{ '<F7>', dapui.toggle, desc = 'Debug: See last session result.' },
unpack(keys),
}
end,
config = function()
local dap = require 'dap'
local dapui = require 'dapui'

require('mason-nvim-dap').setup {
-- Makes a best effort to setup the various debuggers with
-- reasonable debug configurations
automatic_installation = true,

-- You can provide additional configuration to the handlers,
-- see mason-nvim-dap README for more information
handlers = {},

-- You'll need to check that you have the required things installed
-- online, please don't ask me how to install them :)
ensure_installed = {
-- Update this to ensure that you have the debuggers for the langs you want
'delve',
},
}

-- Dap UI setup
-- For more information, see |:help nvim-dap-ui|
dapui.setup {
-- Set icons to characters that are more likely to work in every terminal.
-- Feel free to remove or use ones that you like more! :)
-- Don't feel like these are good choices.
icons = { expanded = '', collapsed = '', current_frame = '*' },
controls = {
icons = {
pause = '',
play = '',
step_into = '',
step_over = '',
step_out = '',
step_back = 'b',
run_last = '▶▶',
terminate = '',
disconnect = '',
},
},
}

dap.listeners.after.event_initialized['dapui_config'] = dapui.open
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
dap.listeners.before.event_exited['dapui_config'] = dapui.close

-- Install golang specific config
require('dap-go').setup {
delve = {
-- On Windows delve must be run attached or it crashes.
-- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring
detached = vim.fn.has 'win32' == 0,
},
}
end,
}
14 changes: 5 additions & 9 deletions lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ return {
-- Useful status updates for LSP
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`

-- `neodev` configures Lua LSP for your Neovim config, runtime and plugins
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
-- used for completion, annotations and signatures of Neovim apis
{ 'folke/neodev.nvim', opts = {} },
{ 'folke/lazydev.nvim', ft = 'lua', opts = {} },
},
config = function()
-- Brief Aside: **What is LSP?**
Expand Down Expand Up @@ -93,10 +93,6 @@ return {
-- or a suggestion from your LSP for this to activate.
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')

-- Opens a popup that displays documentation about the word under your cursor
-- See `:help K` for why this keymap
map('K', vim.lsp.buf.hover, 'Hover Documentation')

-- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
Expand All @@ -107,7 +103,7 @@ return {
--
-- When you move your cursor, the highlights will be cleared (the second autocommand).
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.server_capabilities.documentHighlightProvider then
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = true })
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = event.buf,
Expand All @@ -134,9 +130,9 @@ return {
-- code, if the language server you are using supports them
--
-- This may be unwanted, since they displace some of your code
if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
map('<leader>th', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
end, '[T]oggle Inlay [H]ints')
end
end,
Expand Down

0 comments on commit 12807f4

Please sign in to comment.