diff --git a/init.lua b/init.lua index 656f471..7d1d651 100644 --- a/init.lua +++ b/init.lua @@ -12,7 +12,7 @@ local opt = vim.opt local workman = false -- Set font -o.guifont = 'IosevkaTermSlab Nerd Font:h11:#e-subpixelantialias' +o.guifont = 'IosevkaTermSlab Nerd Font,IosevkaTerm Nerd Font,Iosevka Term Slab,Iosevka:h10:#e-subpixelantialias' g.neovide_floating_z_height = 1 g.neovide_confirm_quit = true -- Confirm closing neovide window when changes are unsaved g.neovide_cursor_smooth_blink = true @@ -337,21 +337,17 @@ require('lazy').setup({ } }}, 'ojroques/nvim-bufdel', - 'bullets-vim/bullets.vim', {'stevearc/conform.nvim', config = function () require'conform'.setup { formatters_by_ft = { html = {"prettier"}, }, - format_on_save = function() - if vim.g.format_on_save then - return { - lsp_fallback = true - } - else - return nil + format_on_save = { + lsp_fallback = true, + filter = function(client) + return client.name == 'rust-analyzer' end - end, + } } vim.api.nvim_create_user_command( 'Conform', @@ -370,6 +366,10 @@ require('lazy').setup({ end}, 'direnv/direnv.vim', 'jbyuki/instant.nvim', + {'mizlan/iswap.nvim', config = function() + require'iswap'.setup {} + vim.keymap.set('', 's', 'ISwapWith', { desc = 'Swap' }) + end}, {'windwp/nvim-projectconfig', opts = { -- Load project configuration when changing directory autocmd = true, @@ -395,7 +395,7 @@ require('lazy').setup({ highlight = { enable = true, disable = {'rust', 'bash'} }, incremental_selection = { enable = true }, }, config = function(_, opts) - require'nvim-treesitter'.setup(opts) + require'nvim-treesitter.configs'.setup(opts) end}, 'windwp/nvim-ts-autotag', {'kevinhwang91/nvim-ufo', dependencies = 'kevinhwang91/promise-async', config = function() @@ -449,8 +449,6 @@ require('lazy').setup({ 'jsonls', 'lemminx', 'lua_ls', - 'nixd', - 'ruff', 'ty', 'vimls', 'yamlls', @@ -535,6 +533,74 @@ require('lazy').setup({ }, }}, {'Saghen/blink.compat', lazy = true, opts = {}}, + {'mfussenegger/nvim-jdtls', dependencies = {'neovim/nvim-lspconfig'}, config = function() + au('FileType', { + pattern = 'java', + callback = function() + local jdtls = require 'jdtls' + jdtls.tests = require'jdtls.tests' + jdtls.dap = require'jdtls.dap' + _G.jdt = jdtls + local lspconfig = require'lspconfig' + + local root_dir = jdtls.setup.find_root({'.git', 'mvnw', 'gradlew'}) + + local config = { + -- The command to launch jdtls with + cmd = { + 'jdtls', + -- Enable logging + '--jvm-arg=-Dlog.level=ALL', + '--jvm-arg=-Dlog.protocol=true', + -- Enable lombok + '--jvm-arg=-javaagent:' .. mason_path('jdtls') .. '/lombok.jar', + -- Shut the warning up + '--jvm-arg=-XX:+EnableDynamicAgentLoading', + -- store workpace data in ~/.local/share/eclipse/ + '-data', vim.fn.expand('~/.local/share/eclipse/') .. vim.fn.fnamemodify(root_dir, ':p:h:t') + }, + + root_dir = root_dir, + + capabilities = lspconfig.util.default_config.capabilities, + + settings = { + java = { + autobuild = { enabled = false }, + }, + }, + + init_options = { + -- JDTLS plugins + bundles = (function() + -- add java-debug-adapter + local bundles = { + vim.fn.glob(mason_path'java-debug-adapter' .. '/extension/server/com.microsoft.java.debug.plugin-*.jar', true) + } + -- add java-test + vim.list_extend(bundles, vim.split( + vim.fn.glob(vim.fn.expand('~/.local/share/vscode-java-test/server') .. '/*.jar', true), + '\n' + )) + + return bundles + end)(), + }, + + on_attach = function(client, bufnr) + jdtls.setup_dap() + vim.keymap.set('n', 'lo', jdtls.organize_imports, { desc = 'Organize imports', buffer = bufnr }) + vim.keymap.set('n', 'Xm', jdtls.test_nearest_method, { desc = 'Test nearest method', buffer = bufnr }) + vim.keymap.set('n', 'Xc', jdtls.test_class, { desc = 'Test class', buffer = bufnr }) + vim.keymap.set('n', 'Xg', jdtls.tests.goto_subjects, { desc = 'Go to test', buffer = bufnr }) + vim.keymap.set('n', 'Xb', 'JdtCompile full', { desc = 'Build', buffer = bufnr }) + end, + } + + jdtls.start_or_attach(config) + end + }) + end}, {'mrcjkb/rustaceanvim', config = function () vim.g.rustaceanvim = { server = { @@ -845,7 +911,7 @@ require('lazy').setup({ {'lucaSartore/nvim-dap-exception-breakpoints', dependencies = {'mfussenegger/nvim-dap'}, config = function() vim.keymap.set('n', 'de', require'nvim-dap-exception-breakpoints', { desc = 'Exception breakpoints'}) end}, - {'dlyongemallo/diffview.nvim', opts = { + {'sindrets/diffview.nvim', opts = { -- Use nicer highlighting for diffs enhanced_diff_hl = true, win_config = { @@ -896,6 +962,8 @@ require('lazy').setup({ } }}, {'tpope/vim-fugitive', lazy = false, dependencies = {'tpope/vim-rhubarb', 'shumphrey/fugitive-gitlab.vim'}, keys = { + {'g', 'vert Git', desc = 'Git status'}, + {'G', 'tab Git', desc = 'Git status (tab)'}, }}, {'harrisoncramer/gitlab.nvim', dependencies = { 'MunifTanjim/nui.nvim', @@ -1002,7 +1070,6 @@ require('lazy').setup({ {'g', 'Neogit', { desc = 'Neogit' }} }}, {'rcarriga/nvim-notify', dependencies = {'nvim-telescope/telescope.nvim'}, opts = { - background_colour = '#FFFFFF', stages = 'fade', render = 'compact', }, config = function(_, opts) @@ -1010,11 +1077,6 @@ require('lazy').setup({ vim.notify = require'notify' require'telescope'.load_extension('notify') end}, - {'pwntester/octo.nvim', dependencies = {'nvim-lua/plenary.nvim', 'nvim-tree/nvim-web-devicons'}, opts = { - picker = 'telescope', - -- Allow using :Octo without arguments - enable_builtin = true, - }}, {'stevearc/overseer.nvim', dependencies = {'folke/which-key.nvim'}, opts = { task_list = { bindings = { @@ -1040,9 +1102,6 @@ require('lazy').setup({ } } end}, - {'michaelb/sniprun', lazy = false, build = 'sh install.sh', keys = { - {'p', 'SnipRun', mode = {'v', 'n'}, desc = 'Run snippet'}, - }}, {'mhinz/vim-startify', init = function() -- Don't change working directory when opening files g.startify_change_to_dir = 0 @@ -1162,12 +1221,13 @@ require('lazy').setup({ require'telescope'.load_extension('undo') end}, {'nvim-neotest/neotest', dependencies = { - --'nvim-neotest/neotest-vim-test', + 'nvim-neotest/neotest-vim-test', + 'rouge8/neotest-rust', }, config = function() require'neotest'.setup { adapters = { - --require'neotest-vim-test' { allow_file_types = {'java'} }, - require'rustaceanvim.neotest' + require'neotest-vim-test' { allow_file_types = {'java'} }, + require'neotest-rust' {}, } } require'which-key'.register {