This commit is contained in:
carldatan 2024-10-19 17:20:34 +08:00
parent 243843f190
commit d8a983e13a
16 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,52 @@
--[[
--
-- This file is not required for your own configuration,
-- but helps people determine if their system is setup correctly.
--
--]]
local check_version = function()
local verstr = string.format('%s.%s.%s', vim.version().major, vim.version().minor, vim.version().patch)
if not vim.version.cmp then
vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr))
return
end
if vim.version.cmp(vim.version(), { 0, 9, 4 }) >= 0 then
vim.health.ok(string.format("Neovim version is: '%s'", verstr))
else
vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr))
end
end
local check_external_reqs = function()
-- Basic utils: `git`, `make`, `unzip`
for _, exe in ipairs { 'git', 'make', 'unzip', 'rg' } do
local is_executable = vim.fn.executable(exe) == 1
if is_executable then
vim.health.ok(string.format("Found executable: '%s'", exe))
else
vim.health.warn(string.format("Could not find executable: '%s'", exe))
end
end
return true
end
return {
check = function()
vim.health.start 'kickstart.nvim'
vim.health.info [[NOTE: Not every warning is a 'must-fix' in `:checkhealth`
Fix only warnings for plugins and languages you intend to use.
Mason will give warnings for languages that are not installed.
You do not need to install, unless you want to use those languages!]]
local uv = vim.uv or vim.loop
vim.health.info('System Information: ' .. vim.inspect(uv.os_uname()))
check_version()
check_external_reqs()
end,
}

View file

@ -0,0 +1,16 @@
-- autopairs
-- https://github.com/windwp/nvim-autopairs
return {
'windwp/nvim-autopairs',
event = 'InsertEnter',
-- Optional dependency
dependencies = { 'hrsh7th/nvim-cmp' },
config = function()
require('nvim-autopairs').setup {}
-- If you want to automatically add `(` after selecting a function or method
local cmp_autopairs = require 'nvim-autopairs.completion.cmp'
local cmp = require 'cmp'
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
end,
}

View file

@ -0,0 +1,163 @@
-- Debugging Support
return {
-- https://github.com/rcarriga/nvim-dap-ui
"rcarriga/nvim-dap-ui",
event = "VeryLazy",
dependencies = {
"nvim-neotest/nvim-nio",
-- https://github.com/mfussenegger/nvim-dap
"mfussenegger/nvim-dap",
-- https://github.com/theHamsta/nvim-dap-virtual-text
"theHamsta/nvim-dap-virtual-text", -- inline variable text while debugging
-- https://github.com/nvim-telescope/telescope-dap.nvim
"nvim-telescope/telescope-dap.nvim", -- telescope integration with dap
},
opts = {
controls = {
element = "repl",
enabled = false,
icons = {
disconnect = "",
pause = "",
play = "",
run_last = "",
step_back = "",
step_into = "",
step_out = "",
step_over = "",
terminate = "",
},
},
element_mappings = {},
expand_lines = true,
floating = {
border = "single",
mappings = {
close = { "q", "<Esc>" },
},
},
force_buffers = true,
icons = {
collapsed = "",
current_frame = "",
expanded = "",
},
layouts = {
{
elements = {
{
id = "scopes",
size = 0.50,
},
{
id = "stacks",
size = 0.30,
},
{
id = "watches",
size = 0.10,
},
{
id = "breakpoints",
size = 0.10,
},
},
size = 40,
position = "left", -- Can be "left" or "right"
},
{
elements = {
"repl",
"console",
},
size = 10,
position = "bottom", -- Can be "bottom" or "top"
},
},
mappings = {
edit = "e",
expand = { "<CR>", "<2-LeftMouse>" },
open = "o",
remove = "d",
repl = "r",
toggle = "t",
},
render = {
indent = 1,
max_value_lines = 100,
},
},
config = function(_, opts)
local dap = require("dap")
local dapui = require("dapui")
require("dapui").setup(opts)
dap.listeners.after.event_initialized["dapui_config"] = function()
require("dapui").open()
end
dap.listeners.before.event_terminated["dapui_config"] = function()
-- Commented to prevent DAP UI from closing when unit tests finish
-- require("dapui").close()
end
dap.listeners.before.event_exited["dapui_config"] = function()
-- Commented to prevent DAP UI from closing when unit tests finish
-- require("dapui").close()
end
-- Add dap configurations based on your language/adapter settings
-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation
dap.configurations.java = {
{
name = "Debug Launch (2GB)",
type = "java",
request = "launch",
vmArgs = "" .. "-Xmx2g ",
},
{
name = "Debug Attach (8000)",
type = "java",
request = "attach",
hostName = "127.0.0.1",
port = 8000,
},
{
name = "Debug Attach (5005)",
type = "java",
request = "attach",
hostName = "127.0.0.1",
port = 5005,
},
{
name = "My Custom Java Run Configuration",
type = "java",
request = "launch",
-- You need to extend the classPath to list your dependencies.
-- `nvim-jdtls` would automatically add the `classPaths` property if it is missing
-- classPaths = {},
-- If using multi-module projects, remove otherwise.
-- projectName = "yourProjectName",
-- javaExec = "java",
mainClass = "replace.with.your.fully.qualified.MainClass",
-- If using the JDK9+ module system, this needs to be extended
-- `nvim-jdtls` would automatically populate this property
-- modulePaths = {},
vmArgs = "" .. "-Xmx2g ",
},
}
-- 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" })
vim.keymap.set("n", "<F7>", dapui.toggle, { desc = "Debug: See last session result." })
end,
}

View file

@ -0,0 +1,61 @@
-- Adds git related signs to the gutter, as well as utilities for managing changes
-- NOTE: gitsigns is already included in init.lua but contains only the base
-- config. This will add also the recommended keymaps.
return {
{
'lewis6991/gitsigns.nvim',
opts = {
on_attach = function(bufnr)
local gitsigns = require 'gitsigns'
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map('n', ']c', function()
if vim.wo.diff then
vim.cmd.normal { ']c', bang = true }
else
gitsigns.nav_hunk 'next'
end
end, { desc = 'Jump to next git [c]hange' })
map('n', '[c', function()
if vim.wo.diff then
vim.cmd.normal { '[c', bang = true }
else
gitsigns.nav_hunk 'prev'
end
end, { desc = 'Jump to previous git [c]hange' })
-- Actions
-- visual mode
map('v', '<leader>hs', function()
gitsigns.stage_hunk { vim.fn.line '.', vim.fn.line 'v' }
end, { desc = 'stage git hunk' })
map('v', '<leader>hr', function()
gitsigns.reset_hunk { vim.fn.line '.', vim.fn.line 'v' }
end, { desc = 'reset git hunk' })
-- normal mode
map('n', '<leader>hs', gitsigns.stage_hunk, { desc = 'git [s]tage hunk' })
map('n', '<leader>hr', gitsigns.reset_hunk, { desc = 'git [r]eset hunk' })
map('n', '<leader>hS', gitsigns.stage_buffer, { desc = 'git [S]tage buffer' })
map('n', '<leader>hu', gitsigns.undo_stage_hunk, { desc = 'git [u]ndo stage hunk' })
map('n', '<leader>hR', gitsigns.reset_buffer, { desc = 'git [R]eset buffer' })
map('n', '<leader>hp', gitsigns.preview_hunk, { desc = 'git [p]review hunk' })
map('n', '<leader>hb', gitsigns.blame_line, { desc = 'git [b]lame line' })
map('n', '<leader>hd', gitsigns.diffthis, { desc = 'git [d]iff against index' })
map('n', '<leader>hD', function()
gitsigns.diffthis '@'
end, { desc = 'git [D]iff against last commit' })
-- Toggles
map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' })
map('n', '<leader>tD', gitsigns.toggle_deleted, { desc = '[T]oggle git show [D]eleted' })
end,
},
},
}

View file

@ -0,0 +1,9 @@
return {
{ -- Add indentation guides even on blank lines
'lukas-reineke/indent-blankline.nvim',
-- Enable `lukas-reineke/indent-blankline.nvim`
-- See `:help ibl`
main = 'ibl',
opts = {},
},
}

View file

@ -0,0 +1,55 @@
return {
{ -- Linting
'mfussenegger/nvim-lint',
event = { 'BufReadPre', 'BufNewFile' },
config = function()
local lint = require 'lint'
lint.linters_by_ft = {
markdown = { 'markdownlint' },
}
-- To allow other plugins to add linters to require('lint').linters_by_ft,
-- instead set linters_by_ft like this:
-- lint.linters_by_ft = lint.linters_by_ft or {}
-- lint.linters_by_ft['markdown'] = { 'markdownlint' }
--
-- However, note that this will enable a set of default linters,
-- which will cause errors unless these tools are available:
-- {
-- clojure = { "clj-kondo" },
-- dockerfile = { "hadolint" },
-- inko = { "inko" },
-- janet = { "janet" },
-- json = { "jsonlint" },
-- markdown = { "vale" },
-- rst = { "vale" },
-- ruby = { "ruby" },
-- terraform = { "tflint" },
-- text = { "vale" }
-- }
--
-- You can disable the default linters by setting their filetypes to nil:
-- lint.linters_by_ft['clojure'] = nil
-- lint.linters_by_ft['dockerfile'] = nil
-- lint.linters_by_ft['inko'] = nil
-- lint.linters_by_ft['janet'] = nil
-- lint.linters_by_ft['json'] = nil
-- lint.linters_by_ft['markdown'] = nil
-- lint.linters_by_ft['rst'] = nil
-- lint.linters_by_ft['ruby'] = nil
-- lint.linters_by_ft['terraform'] = nil
-- lint.linters_by_ft['text'] = nil
-- Create autocommand which carries out the actual linting
-- on the specified events.
local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true })
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
group = lint_augroup,
callback = function()
require('lint').try_lint()
end,
})
end,
},
}

View file

@ -0,0 +1,25 @@
-- Neo-tree is a Neovim plugin to browse the file system
-- https://github.com/nvim-neo-tree/neo-tree.nvim
return {
'nvim-neo-tree/neo-tree.nvim',
version = '*',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended
'MunifTanjim/nui.nvim',
},
cmd = 'Neotree',
keys = {
{ '\\', ':Neotree reveal<CR>', { desc = 'NeoTree reveal' } },
},
opts = {
filesystem = {
window = {
mappings = {
['\\'] = 'close_window',
},
},
},
},
}