diff --git a/ftplugin/java.lua b/ftplugin/java.lua new file mode 100644 index 00000000..8570fdd3 --- /dev/null +++ b/ftplugin/java.lua @@ -0,0 +1,130 @@ +local home = os.getenv('HOME') +local jdtls = require('jdtls') + +-- File types that signify a Java project's root directory. This will be +-- used by eclipse to determine what constitutes a workspace +local root_markers = { 'gradlew', 'mvnw', '.git' } +local root_dir = require('jdtls.setup').find_root(root_markers) + +-- eclipse.jdt.ls stores project specific data within a folder. If you are working +-- with multiple different projects, each project must use a dedicated data directory. +-- This variable is used to configure eclipse to use the directory name of the +-- current project found using the root_marker as the folder for project specific data. +local workspace_folder = home .. "/.local/share/nvim/eclipse/" .. vim.fn.fnamemodify(root_dir, ":p:h:t") + +-- Helper function for creating keymaps +function nnoremap(rhs, lhs, bufopts, desc) + bufopts.desc = desc + vim.keymap.set("n", rhs, lhs, bufopts) +end + +local config = { + flags = { + debounce_text_changes = 80, + }, + on_attach = on_attach, -- We pass our on_attach keybindings to the configuration map + root_dir = root_dir, -- Set the root directory to our found root_marker + -- Here you can configure eclipse.jdt.ls specific settings + -- These are defined by the eclipse.jdt.ls project and will be passed to eclipse when starting. + -- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request + -- for a list of options + settings = { + java = { + format = { + settings = { + -- Use Google Java style guidelines for formatting + -- To use, make sure to download the file from https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml + -- and place it in the ~/.local/share/eclipse directory + url = home .. ".local/share/nvim/eclipse/eclipse-java-google-style.xml", + profile = "GoogleStyle", + }, + }, + signatureHelp = { enabled = true }, + contentProvider = { preferred = 'fernflower' }, -- Use fernflower to decompile library code + -- Specify any completion options + 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.*" + }, + filteredTypes = { + "com.sun.*", + "io.micrometer.shaded.*", + "java.awt.*", + "jdk.*", "sun.*", + }, + }, + -- Specify any options for organizing imports + sources = { + organizeImports = { + starThreshold = 9999, + staticStarThreshold = 9999, + }, + }, + -- How code generation should act + codeGeneration = { + toString = { + template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}" + }, + hashCodeEquals = { + useJava7Objects = true, + }, + useBlocks = true, + }, + -- If you are developing in projects with different Java versions, you need + -- to tell eclipse.jdt.ls to use the location of the JDK for your Java version + -- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request + -- And search for `interface RuntimeOption` + -- The `name` is NOT arbitrary, but must match one of the elements from `enum ExecutionEnvironment` in the link above + configuration = { + runtimes = { + { + name = "JavaSE-17", + path = home .. "/.jkds/corretto-17.0.6", + }, + } + } + } + }, + -- cmd is the command that starts the language server. Whatever is placed + -- here is what is passed to the command line to execute jdtls. + -- Note that eclipse.jdt.ls must be started with a Java version of 17 or higher + -- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line + -- for the full list of options + cmd = { + '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', + '-Xmx4g', + '--add-modules=ALL-SYSTEM', + '--add-opens', 'java.base/java.util=ALL-UNNAMED', + '--add-opens', 'java.base/java.lang=ALL-UNNAMED', + -- If you use lombok, download the lombok jar and place it in ~/.local/share/eclipse + '-javaagent:' .. home .. '/.local/share/nvim/mason/plugins/jdtls/lombok.jar', + + -- The jar file is located where jdtls was installed. This will need to be updated + -- to the location where you installed jdtls + '-jar', + vim.fn.glob(home .. + '.local/share/nvim/mason/packages/jdtls/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar'), + + -- The configuration for jdtls is also placed where jdtls was installed. This will + -- need to be updated depending on your environment + '-configuration', home .. '.local/share/nvim/mason/packages/jdtls/config_linux', + + -- Use the workspace_folder defined above to store data for this project + '-data', workspace_folder, + }, +} + +-- Finally, start jdtls. This will run the language server using the configuration we specified, +-- setup the keymappings, and attach the LSP client to the current buffer +jdtls.start_or_attach(config) diff --git a/init.lua b/init.lua index e6f36728..5d4702a6 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,6 @@ --[[ -===================================================================== +a===================================================================== ==================== READ THIS BEFORE CONTINUING ==================== ===================================================================== Kickctart.nvim is *not* a distribution. @@ -98,7 +98,6 @@ require('lazy').setup({ 'folke/neodev.nvim', }, }, - { -- Autocompletion 'hrsh7th/nvim-cmp', @@ -128,8 +127,6 @@ require('lazy').setup({ }, }, }, - - { -- Add indentation guides even on blank lines 'lukas-reineke/indent-blankline.nvim', @@ -174,6 +171,9 @@ require('lazy').setup({ end, }, + { + 'mfussenegger/nvim-jdtls', + }, -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart -- These are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them. @@ -188,11 +188,12 @@ require('lazy').setup({ -- -- An additional note is that if you only copied in the `init.lua`, you can just comment this line -- to get rid of the warning telling you that there are not plugins in `lua/custom/plugins/`. + -- //wait mason initialize all plugins before import the custom plugins + -- { import = 'custom.plugins' }, }, {}) --- Load custom treesitter grammar for org filetype -require('orgmode').setup_ts_grammar() + -- Treesitter configuration require('nvim-treesitter.configs').setup { @@ -207,17 +208,12 @@ require('nvim-treesitter.configs').setup { ensure_installed = { 'org' }, -- Or run :TSUpdate org } -require('orgmode').setup({ - org_agenda_files = { '~/Notes/org/*', '~/my-orgs/**/*' }, - org_default_notes_file = '~/Notes/org/refile.org', -}) -- [[ Setting options ]] -- See `:help vim.o` -- Set highlight on search vim.o.hlsearch = true -vim.cmd [[highlight Search guifg=#292e42 guibg=#bb9af7]] -- Make line numbers default vim.wo.number = true @@ -333,6 +329,11 @@ vim.api.nvim_set_keymap('i', '', '', { noremap = true, desc = "delete vim.api.nvim_set_keymap('n', 'ol', ":!zathura -expand('%:r').pdf &", { noremap = true, silent = true, desc = "[O]pen [L]atex" }) +vim.api.nvim_set_keymap('n', 'k', "", { noremap = true, silent = true, desc = "" }) + +vim.api.nvim_set_keymap('i', '', "hdiwi", { noremap = true, silent = true, desc = "" }) +vim.api.nvim_set_keymap('n', ':wq', "wqa", { noremap = true, silent = true, desc = "" }) + -- trucco sul relplace. -- selezionare la sezione in cui si vuole rimpiazzare una parola (si puo anche non @@ -562,6 +563,7 @@ local servers = { -- Setup neovim lua configuration require('neodev').setup() + -- nvim-cmp supports additional completion capabilities, so broadcast that to servers local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) @@ -632,6 +634,28 @@ cmp.setup { { name = 'luasnip' }, { name = 'orgmode' }, }, + + require('neorg').setup { + load = { + ["core.defaults"] = {}, + ["core.norg.dirman"] = { + config = { + workspaces = { + work = "~/notes/work", + home = "~/notes/home", + } + }, + ["core.norg.concealer"] = {}, + ["core.norg.completion"] = { + config = { + engine = "nvim-cmp" + } + }, + ["core.norg.esupports.hop"] = {}, + ["core.norg.esupports.neorglink"] = {}, + } + } + } } diff --git a/lua/custom/plugins/latex.lua b/lua/custom/plugins/latex.lua index 5785f751..87dd814f 100644 --- a/lua/custom/plugins/latex.lua +++ b/lua/custom/plugins/latex.lua @@ -3,13 +3,13 @@ return { 'lervag/vimtex', 'sirver/ultisnips', 'KeitaNakamura/tex-conceal.vim', - config = function() - vim.g.UltiSnipsExpandTrigger = '' - vim.g.UltiSnipsJumpForwardTrigger = '' - vim.g.UltiSnipsJumpBackwardTrigger = '' - vim.g.tex_flavor = 'latex' - vim.g.vimtex_view_method = 'zathura' - vim.g.vimtex_quickfix_mode = 0 - vim.g.tex_conceal = 'abdmg', - end + -- config = function() + -- vim.g.UltiSnipsExpandTrigger = '' + -- vim.g.UltiSnipsJumpForwardTrigger = '' + -- vim.g.UltiSnipsJumpBackwardTrigger = '' + -- vim.g.tex_flavor = 'latex' + -- vim.g.vimtex_view_method = 'zathura' + -- vim.g.vimtex_quickfix_mode = 0 + -- vim.g.tex_conceal = 'abdmg', + -- end } diff --git a/lua/custom/plugins/leap.lua b/lua/custom/plugins/leap.lua index 5bf2ed37..284a48be 100644 --- a/lua/custom/plugins/leap.lua +++ b/lua/custom/plugins/leap.lua @@ -5,6 +5,14 @@ return { vim.keymap.set('n', 's', function() local current_window = vim.fn.win_getid() require('leap').leap { target_windows = { current_window } } + require('leap').init_highlight(true) end) + + require('leap').opts = { + + + + + } end } diff --git a/lua/custom/plugins/nabla.lua b/lua/custom/plugins/nabla.lua new file mode 100644 index 00000000..d77e7c17 --- /dev/null +++ b/lua/custom/plugins/nabla.lua @@ -0,0 +1,3 @@ +return { + "jbyuki/nabla.nvim" +} diff --git a/lua/custom/plugins/neorg.lua b/lua/custom/plugins/neorg.lua new file mode 100644 index 00000000..810f2675 --- /dev/null +++ b/lua/custom/plugins/neorg.lua @@ -0,0 +1,18 @@ +return { + "nvim-neorg/neorg", + build = ":Neorg sync-parsers", + opts = { + load = { + ["core.defaults"] = {}, -- Loads default behaviour + ["core.norg.concealer"] = {}, -- Adds pretty icons to your documents + ["core.norg.dirman"] = { -- Manages Neorg workspaces + config = { + workspaces = { + notes = "~/notes", + }, + }, + }, + }, + }, + dependencies = { { "nvim-lua/plenary.nvim" } }, +} diff --git a/lua/custom/plugins/orgomode.lua b/lua/custom/plugins/orgomode.lua deleted file mode 100644 index 777dacf8..00000000 --- a/lua/custom/plugins/orgomode.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - 'nvim-orgmode/orgmode', - ft = { 'org' }, - config = function() - require('orgmode').setup {} - end -} diff --git a/lua/custom/plugins/themes.lua b/lua/custom/plugins/themes.lua index c95d4412..b08c0b48 100644 --- a/lua/custom/plugins/themes.lua +++ b/lua/custom/plugins/themes.lua @@ -1,9 +1,9 @@ return { - { 'folke/tokyonight.nvim', priority = 1000, config = function() + vim.cmd.colorscheme 'tokyonight' end, }, @@ -25,17 +25,27 @@ return { invert_signs = false, invert_tabline = false, invert_intend_guides = false, - inverse = true, -- invert background for search, diffs, statuslines and errors + inverse = false, -- invert background for search, diffs, statuslines and errors contrast = "hard", -- can be "hard", "soft" or empty string - palette_overrides = {}, + palette_overrides = { + + }, overrides = { - SignColumn = { bg = "#1d2021" } + SignColumn = { bg = "#1d2021" }, + LspDiagnosticsSignError = { fg = "#cc241d" }, + LspDiagnosticsSignWarning = { fg = "#d79921" }, + LspDiagnosticsSignInformation = { fg = "#458588" }, + LspDiagnosticsSignHint = { fg = "#b16286" }, + TSAnnotation = { fg = "#A12568" }, + javaAnnotation = { fg = "#A12568" }, }, dim_inactive = false, transparent_mode = false, }) - vim.o.background = "dark" - vim.cmd.colorscheme 'gruvbox' + + -- vim.cmd [[highlight Search guifg=#292e42 guibg=#bb9af7]] + -- vim.o.background = "dark" + -- vim.cmd.colorscheme 'gruvbox' end, }, {