Skip to content

Commit 4055a29

Browse files
Ricardo PerreRicardo Perre
authored andcommitted
this is my current local config
1 parent 3338d39 commit 4055a29

File tree

9 files changed

+1466
-874
lines changed

9 files changed

+1466
-874
lines changed

init.lua

Lines changed: 1060 additions & 874 deletions
Large diffs are not rendered by default.

lua/plugins/autopairs.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- autopairs
2+
-- https://github.com/windwp/nvim-autopairs
3+
4+
return {
5+
'windwp/nvim-autopairs',
6+
event = 'InsertEnter',
7+
opts = {},
8+
}

lua/plugins/debug.lua

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
-- debug.lua
2+
--
3+
-- Shows how to use the DAP plugin to debug your code.
4+
--
5+
-- Primarily focused on configuring the debugger for Go, but can
6+
-- be extended to other languages as well. That's why it's called
7+
-- kickstart.nvim and not kitchen-sink.nvim ;)
8+
9+
return {
10+
-- NOTE: Yes, you can install new plugins here!
11+
"mfussenegger/nvim-dap",
12+
-- NOTE: And you can specify dependencies as well
13+
dependencies = {
14+
-- Creates a beautiful debugger UI
15+
"rcarriga/nvim-dap-ui",
16+
17+
-- Required dependency for nvim-dap-ui
18+
"nvim-neotest/nvim-nio",
19+
20+
-- Installs the debug adapters for you
21+
"williamboman/mason.nvim",
22+
"jay-babu/mason-nvim-dap.nvim",
23+
24+
-- Add your own debuggers here
25+
"leoluz/nvim-dap-go",
26+
},
27+
keys = {
28+
-- Basic debugging keymaps, feel free to change to your liking!
29+
{
30+
"<F5>",
31+
function()
32+
require("dap").continue()
33+
end,
34+
desc = "Debug: Start/Continue",
35+
},
36+
{
37+
"<F1>",
38+
function()
39+
require("dap").step_into()
40+
end,
41+
desc = "Debug: Step Into",
42+
},
43+
{
44+
"<F2>",
45+
function()
46+
require("dap").step_over()
47+
end,
48+
desc = "Debug: Step Over",
49+
},
50+
{
51+
"<F3>",
52+
function()
53+
require("dap").step_out()
54+
end,
55+
desc = "Debug: Step Out",
56+
},
57+
{
58+
"<leader>B",
59+
function()
60+
require("dap").toggle_breakpoint()
61+
end,
62+
desc = "Debug: Toggle Breakpoint",
63+
},
64+
-- {
65+
-- '<leader>B',
66+
-- function()
67+
-- require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ')
68+
-- end,
69+
-- desc = 'Debug: Set Breakpoint',
70+
-- },
71+
-- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
72+
{
73+
"<F7>",
74+
function()
75+
require("dapui").toggle()
76+
end,
77+
desc = "Debug: See last session result.",
78+
},
79+
},
80+
config = function()
81+
local dap = require("dap")
82+
local dapui = require("dapui")
83+
84+
require("mason-nvim-dap").setup({
85+
-- Makes a best effort to setup the various debuggers with
86+
-- reasonable debug configurations
87+
automatic_installation = true,
88+
89+
-- You can provide additional configuration to the handlers,
90+
-- see mason-nvim-dap README for more information
91+
handlers = {},
92+
93+
-- You'll need to check that you have the required things installed
94+
-- online, please don't ask me how to install them :)
95+
ensure_installed = {
96+
-- Update this to ensure that you have the debuggers for the langs you want
97+
"delve",
98+
},
99+
})
100+
101+
-- Dap UI setup
102+
-- For more information, see |:help nvim-dap-ui|
103+
dapui.setup({
104+
-- Set icons to characters that are more likely to work in every terminal.
105+
-- Feel free to remove or use ones that you like more! :)
106+
-- Don't feel like these are good choices.
107+
icons = { expanded = "", collapsed = "", current_frame = "*" },
108+
controls = {
109+
icons = {
110+
pause = "",
111+
play = "",
112+
step_into = "",
113+
step_over = "",
114+
step_out = "",
115+
step_back = "b",
116+
run_last = "▶▶",
117+
terminate = "",
118+
disconnect = "",
119+
},
120+
},
121+
})
122+
123+
-- Change breakpoint icons
124+
-- vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' })
125+
-- vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' })
126+
-- local breakpoint_icons = vim.g.have_nerd_font
127+
-- and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' }
128+
-- or { Breakpoint = '●', BreakpointCondition = '⊜', BreakpointRejected = '⊘', LogPoint = '◆', Stopped = '⭔' }
129+
-- for type, icon in pairs(breakpoint_icons) do
130+
-- local tp = 'Dap' .. type
131+
-- local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak'
132+
-- vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl })
133+
-- end
134+
135+
dap.listeners.after.event_initialized["dapui_config"] = dapui.open
136+
dap.listeners.before.event_terminated["dapui_config"] = dapui.close
137+
dap.listeners.before.event_exited["dapui_config"] = dapui.close
138+
139+
-- Install golang specific config
140+
require("dap-go").setup({
141+
delve = {
142+
-- On Windows delve must be run attached or it crashes.
143+
-- See https://github.com/leoluz/nvim-dap-go/blob/main/README.md#configuring
144+
detached = vim.fn.has("win32") == 0,
145+
},
146+
})
147+
end,
148+
}

lua/plugins/gitsigns.lua

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
-- Adds git related signs to the gutter, as well as utilities for managing changes
2+
-- NOTE: gitsigns is already included in init.lua but contains only the base
3+
-- config. This will add also the recommended keymaps.
4+
5+
return {
6+
{
7+
'lewis6991/gitsigns.nvim',
8+
opts = {
9+
on_attach = function(bufnr)
10+
local gitsigns = require 'gitsigns'
11+
12+
local function map(mode, l, r, opts)
13+
opts = opts or {}
14+
opts.buffer = bufnr
15+
vim.keymap.set(mode, l, r, opts)
16+
end
17+
18+
-- Navigation
19+
map('n', ']c', function()
20+
if vim.wo.diff then
21+
vim.cmd.normal { ']c', bang = true }
22+
else
23+
gitsigns.nav_hunk 'next'
24+
end
25+
end, { desc = 'Jump to next git [c]hange' })
26+
27+
map('n', '[c', function()
28+
if vim.wo.diff then
29+
vim.cmd.normal { '[c', bang = true }
30+
else
31+
gitsigns.nav_hunk 'prev'
32+
end
33+
end, { desc = 'Jump to previous git [c]hange' })
34+
35+
-- Actions
36+
-- visual mode
37+
map('v', '<leader>hs', function()
38+
gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
39+
end, { desc = 'git [s]tage hunk' })
40+
map('v', '<leader>hr', function()
41+
gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' }
42+
end, { desc = 'git [r]eset hunk' })
43+
-- normal mode
44+
map('n', '<leader>hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' })
45+
map('n', '<leader>hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' })
46+
map('n', '<leader>hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' })
47+
map('n', '<leader>hu', gitsigns.stage_hunk, { desc = 'git [u]ndo stage hunk' })
48+
map('n', '<leader>hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' })
49+
map('n', '<leader>hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' })
50+
map('n', '<leader>hb', gitsigns.blame_line, { desc = 'git [b]lame line' })
51+
map('n', '<leader>hd', gitsigns.diffthis, { desc = 'git [d]iff against index' })
52+
map('n', '<leader>hD', function()
53+
gitsigns.diffthis '@'
54+
end, { desc = 'git [D]iff against last commit' })
55+
-- Toggles
56+
map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' })
57+
map('n', '<leader>tD', gitsigns.preview_hunk_inline, { desc = '[T]oggle git show [D]eleted' })
58+
end,
59+
},
60+
},
61+
}

lua/plugins/health.lua

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
--[[
2+
--
3+
-- This file is not required for your own configuration,
4+
-- but helps people determine if their system is setup correctly.
5+
--
6+
--]]
7+
8+
local check_version = function()
9+
local verstr = tostring(vim.version())
10+
if not vim.version.ge then
11+
vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr))
12+
return
13+
end
14+
15+
if vim.version.ge(vim.version(), '0.10-dev') then
16+
vim.health.ok(string.format("Neovim version is: '%s'", verstr))
17+
else
18+
vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr))
19+
end
20+
end
21+
22+
local check_external_reqs = function()
23+
-- Basic utils: `git`, `make`, `unzip`
24+
for _, exe in ipairs { 'git', 'make', 'unzip', 'rg' } do
25+
local is_executable = vim.fn.executable(exe) == 1
26+
if is_executable then
27+
vim.health.ok(string.format("Found executable: '%s'", exe))
28+
else
29+
vim.health.warn(string.format("Could not find executable: '%s'", exe))
30+
end
31+
end
32+
33+
return true
34+
end
35+
36+
return {
37+
check = function()
38+
vim.health.start 'kickstart.nvim'
39+
40+
vim.health.info [[NOTE: Not every warning is a 'must-fix' in `:checkhealth`
41+
42+
Fix only warnings for plugins and languages you intend to use.
43+
Mason will give warnings for languages that are not installed.
44+
You do not need to install, unless you want to use those languages!]]
45+
46+
local uv = vim.uv or vim.loop
47+
vim.health.info('System Information: ' .. vim.inspect(uv.os_uname()))
48+
49+
check_version()
50+
check_external_reqs()
51+
end,
52+
}

lua/plugins/indent_line.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
return {
2+
{ -- Add indentation guides even on blank lines
3+
'lukas-reineke/indent-blankline.nvim',
4+
-- Enable `lukas-reineke/indent-blankline.nvim`
5+
-- See `:help ibl`
6+
main = 'ibl',
7+
opts = {},
8+
},
9+
}

lua/plugins/keymaps.lua

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
-- [[ Basic Keymaps ]]
2+
-- See `:help vim.keymap.set()`
3+
-- Buffer keymaps
4+
vim.keymap.set("n", "<leader>b", "", { desc = "Buffers" })
5+
vim.keymap.set("n", "<leader>bn", "<cmd>bn<cr>", { desc = "Next buffer" })
6+
vim.keymap.set("n", "<leader>bb", "<cmd>bp<cr>", { desc = "Previous buffer" })
7+
vim.keymap.set("n", "<leader>bd", "<cmd>bd<cr>", { desc = "Delete buffer" })
8+
9+
-- window keymaps
10+
vim.keymap.set("n", "<leader>q", "<cmd>bd<cr>", { desc = "Quit" })
11+
vim.keymap.set("n", "<leader>Q", "<cmd>q<cr>", { desc = "Quit All" })
12+
vim.keymap.set("n", "<leader>w", "<cmd>w<CR>", { desc = "Save" })
13+
vim.keymap.set("n", "<leader>W", "<cmd>wa<CR>", { desc = "Save All" })
14+
-- Diagnostic keymaps
15+
-- vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "Open diagnostic [Q]uickfix list" })
16+
17+
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
18+
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
19+
-- is not what someone will guess without a bit more experience.
20+
--
21+
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
22+
-- or just use <C-\><C-n> to exit terminal mode
23+
vim.keymap.set("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "Exit terminal mode" })
24+
25+
-- TIP: Disable arrow keys in normal mode
26+
vim.keymap.set("n", "<left>", '<cmd>echo "Use h to move!!"<CR>')
27+
vim.keymap.set("n", "<right>", '<cmd>echo "Use l to move!!"<CR>')
28+
vim.keymap.set("n", "<up>", '<cmd>echo "Use k to move!!"<CR>')
29+
vim.keymap.set("n", "<down>", '<cmd>echo "Use j to move!!"<CR>')
30+
-- Keybinds to make split navigation easier.
31+
-- Use CTRL+<hjkl> to switch between windows
32+
--
33+
-- See `:help wincmd` for a list of all window commands
34+
vim.keymap.set("n", "<C-h>", "<C-w><C-h>", { desc = "Move focus to the left window" })
35+
vim.keymap.set("n", "<C-l>", "<C-w><C-l>", { desc = "Move focus to the right window" })
36+
vim.keymap.set("n", "<C-j>", "<C-w><C-j>", { desc = "Move focus to the lower window" })
37+
vim.keymap.set("n", "<C-k>", "<C-w><C-k>", { desc = "Move focus to the upper window" })
38+
39+
-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes
40+
-- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" })
41+
-- vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" })
42+
-- vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" })
43+
-- vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" })

lua/plugins/lint.lua

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
return {
2+
3+
{ -- Linting
4+
'mfussenegger/nvim-lint',
5+
event = { 'BufReadPre', 'BufNewFile' },
6+
config = function()
7+
local lint = require 'lint'
8+
lint.linters_by_ft = {
9+
markdown = { 'markdownlint' },
10+
}
11+
12+
-- To allow other plugins to add linters to require('lint').linters_by_ft,
13+
-- instead set linters_by_ft like this:
14+
-- lint.linters_by_ft = lint.linters_by_ft or {}
15+
-- lint.linters_by_ft['markdown'] = { 'markdownlint' }
16+
--
17+
-- However, note that this will enable a set of default linters,
18+
-- which will cause errors unless these tools are available:
19+
-- {
20+
-- clojure = { "clj-kondo" },
21+
-- dockerfile = { "hadolint" },
22+
-- inko = { "inko" },
23+
-- janet = { "janet" },
24+
-- json = { "jsonlint" },
25+
-- markdown = { "vale" },
26+
-- rst = { "vale" },
27+
-- ruby = { "ruby" },
28+
-- terraform = { "tflint" },
29+
-- text = { "vale" }
30+
-- }
31+
--
32+
-- You can disable the default linters by setting their filetypes to nil:
33+
-- lint.linters_by_ft['clojure'] = nil
34+
-- lint.linters_by_ft['dockerfile'] = nil
35+
-- lint.linters_by_ft['inko'] = nil
36+
-- lint.linters_by_ft['janet'] = nil
37+
-- lint.linters_by_ft['json'] = nil
38+
-- lint.linters_by_ft['markdown'] = nil
39+
-- lint.linters_by_ft['rst'] = nil
40+
-- lint.linters_by_ft['ruby'] = nil
41+
-- lint.linters_by_ft['terraform'] = nil
42+
-- lint.linters_by_ft['text'] = nil
43+
44+
-- Create autocommand which carries out the actual linting
45+
-- on the specified events.
46+
local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true })
47+
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
48+
group = lint_augroup,
49+
callback = function()
50+
-- Only run the linter in buffers that you can modify in order to
51+
-- avoid superfluous noise, notably within the handy LSP pop-ups that
52+
-- describe the hovered symbol using Markdown.
53+
if vim.bo.modifiable then
54+
lint.try_lint()
55+
end
56+
end,
57+
})
58+
end,
59+
},
60+
}

0 commit comments

Comments
 (0)