add vim-fugitive

This commit is contained in:
Lucas Garcia Rubio 2025-02-26 13:28:49 -03:00
parent 5636d0e913
commit 044d74b814
10 changed files with 392 additions and 16 deletions

160
ftplugin/java.lua Normal file
View File

@ -0,0 +1,160 @@
-- JDTLS (Java LSP) configuration
local home = vim.env.HOME -- Get the home directory
local jdtls = require 'jdtls'
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
local workspace_dir = home .. '/jdtls-workspace/' .. project_name
local system_os = ''
-- Determine OS
if vim.fn.has 'mac' == 1 then
system_os = 'mac'
elseif vim.fn.has 'unix' == 1 then
system_os = 'linux'
elseif vim.fn.has 'win32' == 1 or vim.fn.has 'win64' == 1 then
system_os = 'win'
else
print "OS not found, defaulting to 'linux'"
system_os = 'linux'
end
-- Needed for debugging
local bundles = {
vim.fn.glob(home .. '/.local/share/nvim/mason/share/java-debug-adapter/com.microsoft.java.debug.plugin.jar'),
}
-- Needed for running/debugging unit tests
vim.list_extend(bundles, vim.split(vim.fn.glob(home .. '/.local/share/nvim/mason/share/java-test/*.jar', 1), '\n'))
-- See `:help vim.lsp.start_client` for an overview of the supported `config` options.
local config = {
-- The command that starts the language server
-- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line
cmd = {
'/home/lucas/.sdkman/candidates/java/21.0.2-open/bin/java',
'-Declipse.application=org.eclipse.jdt.ls.core.id1',
'-Dosgi.bundles.defaultStartLevel=4',
'-Declipse.product=org.eclipse.jdt.ls.core.product',
'-Dlog.protocol=true',
'-Dlog.level=ALL',
'-javaagent:' .. home .. '/.local/share/nvim/mason/share/jdtls/lombok.jar',
'-Xmx4g',
'--add-modules=ALL-SYSTEM',
'--add-opens',
'java.base/java.util=ALL-UNNAMED',
'--add-opens',
'java.base/java.lang=ALL-UNNAMED',
-- Eclipse jdtls location
'-jar',
home .. '/.local/share/nvim/mason/share/jdtls/plugins/org.eclipse.equinox.launcher.jar',
'-configuration',
home .. '/.local/share/nvim/mason/packages/jdtls/config_' .. system_os,
'-data',
workspace_dir,
},
-- This is the default if not provided, you can remove it. Or adjust as needed.
-- One dedicated LSP server & client will be started per unique root_dir
root_dir = vim.fs.root(0, { '.git', 'mvnw', 'gradlew' }),
-- Here you can configure eclipse.jdt.ls specific settings
-- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
settings = {
java = {
home = '/home/lucas/.sdkman/candidates/java/21.0.2-open',
eclipse = {
downloadSources = true,
},
configuration = {
updateBuildConfiguration = 'interactive',
-- TODO Update this by adding any runtimes that you need to support your Java projects and removing any that you don't have installed
-- The runtime name parameters need to match specific Java execution environments. See https://github.com/tamago324/nlsp-settings.nvim/blob/2a52e793d4f293c0e1d61ee5794e3ff62bfbbb5d/schemas/_generated/jdtls.json#L317-L334
runtimes = {
{
name = 'JavaSE-11',
path = '/home/lucas/.sdkman/candidates/java/11.0.22-ms',
},
{
name = 'JavaSE-21',
path = '/home/lucas/.sdkman/candidates/java/21.0.2-open',
},
},
},
maven = {
downloadSources = true,
},
implementationsCodeLens = {
enabled = true,
},
referencesCodeLens = {
enabled = true,
},
references = {
includeDecompiledSources = true,
},
signatureHelp = { enabled = true },
format = {
enabled = true,
-- Formatting works by default, but you can refer to a specific file/URL if you choose
-- settings = {
-- url = "https://github.com/google/styleguide/blob/gh-pages/intellij-java-google-style.xml",
-- profile = "GoogleStyle",
-- },
},
completion = {
favoriteStaticMembers = {
'org.hamcrest.MatcherAssert.assertThat',
'org.hamcrest.Matchers.*',
'org.hamcrest.CoreMatchers.*',
'org.junit.jupiter.api.Assertions.*',
'java.util.Objects.requireNonNull',
'java.util.Objects.requireNonNullElse',
'org.mockito.Mockito.*',
},
importOrder = {
'java',
'javax',
'lombok',
'springfox',
'org',
'com',
'io',
'br',
},
},
sources = {
organizeImports = {
starThreshold = 9999,
staticStarThreshold = 9999,
},
},
codeGeneration = {
toString = {
template = '${object.className}{${member.name()}=${member.value}, ${otherMembers}}',
},
useBlocks = true,
},
},
},
-- Needed for auto-completion with method signatures and placeholders
capabilities = require('cmp_nvim_lsp').default_capabilities(),
flags = {
allow_incremental_sync = true,
},
init_options = {
-- References the bundles defined above to support Debugging and Unit Testing
bundles = bundles,
extendedClientCapabilities = jdtls.extendedClientCapabilities,
},
}
-- Needed for debugging
config['on_attach'] = function(client, bufnr)
jdtls.setup_dap { hotcodereplace = 'auto' }
require('jdtls.dap').setup_dap_main_class_configs()
end
-- This starts a new client & server, or attaches to an existing client & server based on the `root_dir`.
jdtls.start_or_attach(config)

View File

@ -91,7 +91,7 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' ' vim.g.maplocalleader = ' '
-- Set to true if you have a Nerd Font installed and selected in the terminal -- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = false vim.g.have_nerd_font = true
-- [[ Setting options ]] -- [[ Setting options ]]
-- See `:help vim.opt` -- See `:help vim.opt`
@ -652,7 +652,6 @@ require('lazy').setup({
-- :Mason -- :Mason
-- --
-- You can press `g?` for help in this menu. -- You can press `g?` for help in this menu.
require('mason').setup()
-- --
-- `mason` had to be setup earlier: to configure its options see the -- `mason` had to be setup earlier: to configure its options see the
-- `dependencies` table for `nvim-lspconfig` above. -- `dependencies` table for `nvim-lspconfig` above.
@ -662,9 +661,14 @@ require('lazy').setup({
local ensure_installed = vim.tbl_keys(servers or {}) local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, { vim.list_extend(ensure_installed, {
'stylua', -- Used to format Lua code 'stylua', -- Used to format Lua code
'java-debug-adapter',
'java-test',
'prettier', 'prettier',
'eslint_d',
}) })
require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-tool-installer').setup { ensure_installed = ensure_installed }
-- Enable navigation in flutuate windows
local cmp = require 'cmp' local cmp = require 'cmp'
cmp.setup { cmp.setup {
mapping = { mapping = {
@ -674,6 +678,7 @@ require('lazy').setup({
} }
require('mason-lspconfig').setup { require('mason-lspconfig').setup {
ensure_installed = { 'jdtls' },
handlers = { handlers = {
function(server_name) function(server_name)
local server = servers[server_name] or {} local server = servers[server_name] or {}
@ -681,7 +686,9 @@ require('lazy').setup({
-- by the server configuration above. Useful when disabling -- by the server configuration above. Useful when disabling
-- certain features of an LSP (for example, turning off formatting for ts_ls) -- certain features of an LSP (for example, turning off formatting for ts_ls)
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
if server_name ~= 'jdtls' then
require('lspconfig')[server_name].setup(server) require('lspconfig')[server_name].setup(server)
end
end, end,
}, },
} }
@ -928,6 +935,7 @@ require('lazy').setup({
'typescript', 'typescript',
'yaml', 'yaml',
'css', 'css',
'sql',
}, },
-- Autoinstall languages that are not installed -- Autoinstall languages that are not installed
auto_install = true, auto_install = true,
@ -959,7 +967,7 @@ require('lazy').setup({
-- --
require 'kickstart.plugins.debug', require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line', -- require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint', require 'kickstart.plugins.lint',
require 'kickstart.plugins.autopairs', require 'kickstart.plugins.autopairs',
require 'kickstart.plugins.neo-tree', require 'kickstart.plugins.neo-tree',
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
@ -970,7 +978,6 @@ require('lazy').setup({
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
{ import = 'custom.plugins' }, { import = 'custom.plugins' },
-- vim.keymap.set('n', '|', ':Neotree reveal<CR>', { desc = 'Toggle Neotree window', silent = true }),
-- --
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
-- Or use telescope! -- Or use telescope!

View File

@ -12,24 +12,31 @@
"mason-nvim-dap.nvim": { "branch": "main", "commit": "09220b99d63d5363f219daa2785242ee5fddba7f" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "09220b99d63d5363f219daa2785242ee5fddba7f" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "374c78d3ebb5c53f43ea6bd906b6587b5e899b9e" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "374c78d3ebb5c53f43ea6bd906b6587b5e899b9e" },
"mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" },
"mini.nvim": { "branch": "main", "commit": "f89f4e20dc998d8f0cb8b21734877a64a9adee92" }, "mini.nvim": { "branch": "main", "commit": "b612a069d1fe99300da43629e0e9c7a1a9b0acda" },
"neo-tree.nvim": { "branch": "main", "commit": "e96fd85bf18bc345dab332b345098fa5460dffac" }, "neo-tree.nvim": { "branch": "main", "commit": "e96fd85bf18bc345dab332b345098fa5460dffac" },
"neotest": { "branch": "master", "commit": "d66cf4e05a116957f0d3a7755a24291c7d1e1f72" },
"neotest-java": { "branch": "main", "commit": "bbbad04bda7af216a8c24509d47d1f51356b37ce" },
"nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" },
"nvim-autopairs": { "branch": "master", "commit": "68f0e5c3dab23261a945272032ee6700af86227a" }, "nvim-autopairs": { "branch": "master", "commit": "68f0e5c3dab23261a945272032ee6700af86227a" },
"nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" }, "nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" },
"nvim-dap": { "branch": "master", "commit": "52302f02fea3a490e55475de52fa4deb8af2eb11" }, "nvim-dap": { "branch": "master", "commit": "6e0e8ab4d8ed520076971465a4388dfe54a91d83" },
"nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" },
"nvim-dap-ui": { "branch": "master", "commit": "bc81f8d3440aede116f821114547a476b082b319" }, "nvim-dap-ui": { "branch": "master", "commit": "bc81f8d3440aede116f821114547a476b082b319" },
"nvim-lspconfig": { "branch": "master", "commit": "7c8cb61b21727a473663054edec4b83633d9e442" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "df66808cd78b5a97576bbaeee95ed5ca385a9750" },
"nvim-jdtls": { "branch": "master", "commit": "2f7bff9b8d2ee1918b36ca55f19547d9d335a268" },
"nvim-lint": { "branch": "master", "commit": "6e9dd545a1af204c4022a8fcd99727ea41ffdcc8" },
"nvim-lspconfig": { "branch": "master", "commit": "6b63bdf2399b9bedf93297d98419550523a9ad68" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-treesitter": { "branch": "master", "commit": "4cf2da5c3a2dfd22e72713c66203d21883b149fd" }, "nvim-treesitter": { "branch": "master", "commit": "5774e7d3da4f681296a87fcd85d17779ad362a4f" },
"nvim-web-devicons": { "branch": "master", "commit": "1020869742ecb191f260818234517f4a1515cfe8" },
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
"telescope-dap.nvim": { "branch": "master", "commit": "783366bd6c1e7fa0a5c59c07db37f49c805a28df" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "2a5ceff981501cff8f46871d5402cd3378a8ab6a" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "2a5ceff981501cff8f46871d5402cd3378a8ab6a" },
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
"telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" },
"tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" },
"typescript-tools.nvim": { "branch": "master", "commit": "35e397ce467bedbbbb5bfcd0aa79727b59a08d4a" }, "vim-fugitive": { "branch": "master", "commit": "4a745ea72fa93bb15dd077109afbb3d1809383f2" },
"vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" },
"which-key.nvim": { "branch": "main", "commit": "5bf7a73fe851896d5ac26d313db849bf00f45b78" } "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }
} }

View File

@ -0,0 +1,28 @@
return {
{
'rcasia/neotest-java',
ft = 'java',
dependencies = {
'mfussenegger/nvim-jdtls',
'mfussenegger/nvim-dap', -- for the debugger
'rcarriga/nvim-dap-ui', -- recommended
'theHamsta/nvim-dap-virtual-text', -- recommended
},
},
{
'nvim-neotest/neotest',
dependencies = {
'rcasia/neotest-java',
'nvim-neotest/nvim-nio',
'nvim-lua/plenary.nvim',
'nvim-treesitter/nvim-treesitter',
},
init = function()
require('neotest').setup {
adapters = {
require 'neotest-java' {},
},
}
end,
},
}

View File

@ -0,0 +1,143 @@
-- Debugging Support
return {
-- https://github.com/rcarriga/nvim-dap-ui
'rcarriga/nvim-dap-ui',
event = 'VeryLazy',
dependencies = {
-- https://github.com/mfussenegger/nvim-dap
'mfussenegger/nvim-dap',
-- https://github.com/nvim-neotest/nvim-nio
'nvim-neotest/nvim-nio',
-- 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'
require('dapui').setup(opts)
-- Customize breakpoint signs
vim.api.nvim_set_hl(0, 'DapStoppedHl', { fg = '#98BB6C', bg = '#2A2A2A', bold = true })
vim.api.nvim_set_hl(0, 'DapStoppedLineHl', { bg = '#204028', bold = true })
vim.fn.sign_define('DapStopped', { text = '', texthl = 'DapStoppedHl', linehl = 'DapStoppedLineHl', numhl = '' })
vim.fn.sign_define('DapBreakpoint', { text = '', texthl = 'DiagnosticSignError', linehl = '', numhl = '' })
vim.fn.sign_define('DapBreakpointCondition', { text = '', texthl = 'DiagnosticSignWarn', linehl = '', numhl = '' })
vim.fn.sign_define('DapBreakpointRejected', { text = '', texthl = 'DiagnosticSignError', linehl = '', numhl = '' })
vim.fn.sign_define('DapLogPoint', { text = '', texthl = 'DiagnosticSignInfo', linehl = '', numhl = '' })
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,
},
}
end,
}

View File

@ -0,0 +1,17 @@
return {
-- https://github.com/theHamsta/nvim-dap-virtual-text
'theHamsta/nvim-dap-virtual-text',
lazy = true,
opts = {
-- Display debug text as a comment
commented = true,
-- Customize virtual text
display_callback = function(variable, buf, stackframe, node, options)
if options.virt_text_pos == 'inline' then
return ' = ' .. variable.value
else
return variable.name .. ' = ' .. variable.value
end
end,
},
}

View File

@ -0,0 +1,4 @@
return {
'mfussenegger/nvim-jdtls',
ft = 'java',
}

View File

@ -1,7 +1,7 @@
return { return {
{ -- {
'pmizio/typescript-tools.nvim', -- 'pmizio/typescript-tools.nvim',
dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' }, -- dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' },
opts = {}, -- opts = {},
}, -- },
} }

View File

@ -0,0 +1,5 @@
return {
{
'tpope/vim-fugitive',
},
}

View File

@ -7,6 +7,8 @@ return {
local lint = require 'lint' local lint = require 'lint'
lint.linters_by_ft = { lint.linters_by_ft = {
markdown = { 'markdownlint' }, markdown = { 'markdownlint' },
javascript = { 'eslint_d' },
typescript = { 'eslint_d' },
} }
-- To allow other plugins to add linters to require('lint').linters_by_ft, -- To allow other plugins to add linters to require('lint').linters_by_ft,
@ -41,6 +43,9 @@ return {
-- lint.linters_by_ft['terraform'] = nil -- lint.linters_by_ft['terraform'] = nil
-- lint.linters_by_ft['text'] = nil -- lint.linters_by_ft['text'] = nil
-- Enable lint virtual text, which is false by default
vim.diagnostic.config { virtual_text = true }
-- Create autocommand which carries out the actual linting -- Create autocommand which carries out the actual linting
-- on the specified events. -- on the specified events.
local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true })