diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..bba3837 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,5 @@ +require('user.plugins') +require('user.options') +require('user.lsp') +require('user.dap') +require('user.bindings') diff --git a/nvim/init.vim b/nvim/init.vim deleted file mode 100644 index db70da4..0000000 --- a/nvim/init.vim +++ /dev/null @@ -1,55 +0,0 @@ -filetype plugin on -syntax on -set number -set nowrap -set wildmode=longest,list -set colorcolumn=120 -let $NVIM_TUI_ENABLE_TRUE_COLOR=1 -let g:gruvbox_contrast_dark='hard' -let g:gruvbox_hls_cursor='red' -set tabpagemax=500 - -" Indentation -set smartindent -set tabstop=4 -set softtabstop=4 -set shiftwidth=4 -set expandtab -set cursorcolumn -set cursorline - -" Search -set incsearch -set hlsearch -set ignorecase -set smartcase - -" Whitespaces -set listchars=tab:>-,trail:· -set list - -" Terminal mode -:tnoremap - -" File handling -set hidden - -" Custom shortcuts -map gb :bn -map gB :bp -map g# :b# - -" Close the completion preview window (docstring) automatically -autocmd CompleteDone * pclose - -" LSP config -lua <"] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.close(), - -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [''] = cmp.mapping.confirm({ select = false }), - }), - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "buffer" }, - { name = "path" }, - }), - }) - - vim.cmd([[ - set completeopt=menuone,noinsert,noselect - highlight! default link CmpItemKind CmpItemMenuDefault - ]]) - end, -} +local cmp = require("cmp") +cmp.setup({ + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + [''] = cmp.mapping.confirm({ select = false }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "buffer" }, + { name = "path" }, + }), +}) diff --git a/nvim/lua/plugins/colorscheme.lua b/nvim/lua/plugins/colorscheme.lua deleted file mode 100644 index c2b976a..0000000 --- a/nvim/lua/plugins/colorscheme.lua +++ /dev/null @@ -1,14 +0,0 @@ -return { - { - "ellisonleao/gruvbox.nvim", - priority = 1000 , - config = true, - init = function() - require("gruvbox").setup({ - contrast = "hard", - hls_cursor = "red", - }) - vim.cmd("colorscheme gruvbox") - end - } -} diff --git a/nvim/lua/plugins/dap-go.lua b/nvim/lua/plugins/dap-go.lua index 33adaa6..776ed00 100644 --- a/nvim/lua/plugins/dap-go.lua +++ b/nvim/lua/plugins/dap-go.lua @@ -1,11 +1,5 @@ -return { - "leoluz/nvim-dap-go", - dependencies = { - "https://codeberg.org/mfussenegger/nvim-dap", - }, - lazy = true, - ft = { "go" }, - config = function() - require('dap-go').setup() - end, -} +vim.pack.add({ + gh("leoluz/nvim-dap-go"), +}) + +require('dap-go').setup() diff --git a/nvim/lua/plugins/dap-ui.lua b/nvim/lua/plugins/dap-ui.lua deleted file mode 100644 index 9a9a2c4..0000000 --- a/nvim/lua/plugins/dap-ui.lua +++ /dev/null @@ -1,31 +0,0 @@ -return { - "rcarriga/nvim-dap-ui", - dependencies = { - "nvim-neotest/nvim-nio", - { - "theHamsta/nvim-dap-virtual-text", - opts = {}, - }, - }, - lazy = true, - ft = { "java", "go", "python" }, - keys = { - { "du", function() require("dapui").toggle({ }) end, desc = "Dap UI" }, - { "de", function() require("dapui").eval() end, desc = "Eval", mode = {"n", "v"} }, - }, - opts = {}, - config = function(_, opts) - local dap = require("dap") - local dapui = require("dapui") - dapui.setup(opts) - dap.listeners.after.event_initialized["dapui_config"] = function() - dapui.open({}) - end - dap.listeners.before.event_terminated["dapui_config"] = function() - dapui.close({}) - end - dap.listeners.before.event_exited["dapui_config"] = function() - dapui.close({}) - end - end, -} diff --git a/nvim/lua/plugins/dap.lua b/nvim/lua/plugins/dap.lua index 6642065..e2ee74b 100644 --- a/nvim/lua/plugins/dap.lua +++ b/nvim/lua/plugins/dap.lua @@ -1,37 +1,20 @@ -return { - "https://codeberg.org/mfussenegger/nvim-dap", - lazy = true, - ft = { "java", "go", "python" }, - dependencies = { - "rcarriga/nvim-dap-ui", - { - "theHamsta/nvim-dap-virtual-text", - opts = {}, - }, - }, - keys = { - { "", function() require("dap").continue() end, desc = "Continue" }, - { "", function() require("dap").step_over() end, desc = "Step over" }, - { "", function() require("dap").step_into() end, desc = "Step into" }, - { "", function() require("dap").step_out() end, desc = "Step out" }, - { "b", function() require("dap").toggle_breakpoint() end, desc = "Toggle " }, - { "d", "", desc = "+debug", mode = {"n", "v"} }, - { "dB", function() require("dap").set_breakpoint(vim.fn.input('Breakpoint condition: ')) end, desc = "Breakpoint Condition" }, - { "db", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" }, - { "dc", function() require("dap").continue() end, desc = "Continue" }, - { "da", function() require("dap").continue({ before = get_args }) end, desc = "Run with Args" }, - { "dC", function() require("dap").run_to_cursor() end, desc = "Run to Cursor" }, - { "dg", function() require("dap").goto_() end, desc = "Go to Line (No Execute)" }, - { "di", function() require("dap").step_into() end, desc = "Step Into" }, - { "dj", function() require("dap").down() end, desc = "Down" }, - { "dk", function() require("dap").up() end, desc = "Up" }, - { "dl", function() require("dap").run_last() end, desc = "Run Last" }, - { "do", function() require("dap").step_out() end, desc = "Step Out" }, - { "dO", function() require("dap").step_over() end, desc = "Step Over" }, - { "dp", function() require("dap").pause() end, desc = "Pause" }, - { "dr", function() require("dap").repl.toggle() end, desc = "Toggle REPL" }, - { "ds", function() require("dap").session() end, desc = "Session" }, - { "dt", function() require("dap").terminate() end, desc = "Terminate" }, - { "dw", function() require("dap.ui.widgets").hover() end, desc = "Widgets" }, - }, -} +vim.pack.add({ + cb("mfussenegger/nvim-dap"), + gh("rcarriga/nvim-dap-ui"), + gh("theHamsta/nvim-dap-virtual-text"), + gh("rcarriga/nvim-dap-ui"), + gh("nvim-neotest/nvim-nio"), +}) + +local dap = require("dap") +local dapui = require("dapui") +dapui.setup(opts) +dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open({}) +end +dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close({}) +end +dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close({}) +end diff --git a/nvim/lua/plugins/gitsigns.lua b/nvim/lua/plugins/gitsigns.lua index 3ca0639..132b683 100644 --- a/nvim/lua/plugins/gitsigns.lua +++ b/nvim/lua/plugins/gitsigns.lua @@ -1,6 +1,5 @@ -return { - "lewis6991/gitsigns.nvim", - config = function() - require("gitsigns").setup() - end -} +vim.pack.add({ + gh("lewis6991/gitsigns.nvim"), +}) + +require("gitsigns").setup() diff --git a/nvim/lua/plugins/gruvbox.lua b/nvim/lua/plugins/gruvbox.lua new file mode 100644 index 0000000..55206c1 --- /dev/null +++ b/nvim/lua/plugins/gruvbox.lua @@ -0,0 +1,8 @@ +vim.pack.add({ + gh("ellisonleao/gruvbox.nvim"), +}) + +require("gruvbox").setup({ + contrast = "hard", + hls_cursor = "red", +}) diff --git a/nvim/lua/plugins/jdtls.lua b/nvim/lua/plugins/jdtls.lua index 3b5f99d..b9a8df2 100644 --- a/nvim/lua/plugins/jdtls.lua +++ b/nvim/lua/plugins/jdtls.lua @@ -1,27 +1,3 @@ -return { - "https://codeberg.org/mfussenegger/nvim-jdtls", - lazy = true, - ft = { "java" }, - config = function() - local dap = require('dap') - dap.configurations.java = {{ - type = 'java', - request = 'attach', - name = 'Debug (Attach) port 5005', - hostName = '127.0.0.1', - port = 5005, - },{ - type = 'java', - request = 'attach', - name = 'Debug (Attach) port 5006', - hostName = '127.0.0.1', - port = 5006, - },{ - type = 'java', - request = 'attach', - name = 'Debug (Attach) port 5105', - hostName = '127.0.0.1', - port = 5105, - }} - end, -} +vim.pack.add({ + cb("mfussenegger/nvim-jdtls"), +}) diff --git a/nvim/lua/plugins/lspconfig.lua b/nvim/lua/plugins/lspconfig.lua index 9803cc5..f2453cf 100644 --- a/nvim/lua/plugins/lspconfig.lua +++ b/nvim/lua/plugins/lspconfig.lua @@ -1,127 +1,3 @@ -return { - "neovim/nvim-lspconfig", - event = { "BufReadPre", "BufNewFile" }, - dependencies = { - "hrsh7th/cmp-nvim-lsp", - }, - keys = { - { "e", vim.diagnostic.open_float }, - { "[d", vim.diagnostic.goto_prev }, - { "]d", vim.diagnostic.goto_next }, - { "q", vim.diagnostic.setloclist }, - { "gD", vim.lsp.buf.declaration }, - { "gd", vim.lsp.buf.definition }, - { "K", vim.lsp.buf.hover }, - { "gi", vim.lsp.buf.implementation }, - { "", vim.lsp.buf.signature_help }, - { "D", vim.lsp.buf.type_definition }, - { "rn", vim.lsp.buf.rename }, - { "ca", vim.lsp.buf.code_action }, - { "gr", vim.lsp.buf.references }, - { - "f", - function() - vim.lsp.buf.format { async = true } - end - }, - }, - config = function() - - local on_attach = function(client, bufnr) - -- Format on save - if client.server_capabilities.documentFormattingProvider then - vim.api.nvim_create_autocmd("BufWritePre", { - group = vim.api.nvim_create_augroup("Format", { clear = true }), - buffer = bufnr, - callback = function() - vim.lsp.buf.format() - end, - }) - end - end - - -- Typos - vim.lsp.config("typos_lsp", { - settings = { - filetypes = { - 'java', - 'go' - }, - }, - init_options = { - diagnosticSeverity = "Hint", - } - }) - - -- HTML - vim.lsp.enable('html') - - -- CSS - vim.lsp.enable('cssls') - - -- JSON - vim.lsp.enable('jsonls') - - -- Python - vim.lsp.enable('pylsp') - - -- Go - vim.lsp.config("gopls", { - settings = { - gopls = { - gofumpt = true, - staticcheck = true, - analyses = { - unusedparams = true, - unusedresult = true, - unusedwrite = true, - unusedvariable = true, - useany = true, - fieldalignment = false, - nilness = true, - shadow = true, - }, - hints = { - assignVariableTypes = true, - compositeLiteralFields = true, - compositeLiteralTypes = true, - constantValues = true, - functionTypeParameters = true, - parameterNames = true, - rangeVariableTypes = true, - }, - codelenses = { - gc_details = true, - generate = true, - regenerate_cgo = true, - tidy = true, - upgrade_dependency = true, - vendor = true, - }, - }, - }, - }) - -- Organize imports and format code on save - vim.api.nvim_create_autocmd({"BufWritePre"}, { - pattern = "*.go", - callback = function() - local params = vim.lsp.util.make_range_params() - params.context = {only = {"source.organizeImports"}} - local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params) - for cid, res in pairs(result or {}) do - for _, r in pairs(res.result or {}) do - if r.edit then - local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or "utf-16" - vim.lsp.util.apply_workspace_edit(r.edit, enc) - end - end - end - vim.lsp.buf.format({async = false}) - end - }) - vim.lsp.enable('gopls') - - -- PHP - vim.lsp.enable('phpactor') - end, -} +vim.pack.add({ + gh("neovim/nvim-lspconfig"), +}) diff --git a/nvim/lua/plugins/lualine.lua b/nvim/lua/plugins/lualine.lua index 473c340..5727aa8 100644 --- a/nvim/lua/plugins/lualine.lua +++ b/nvim/lua/plugins/lualine.lua @@ -1,7 +1,5 @@ -return { - "nvim-lualine/lualine.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - config = function() - require("lualine").setup() - end, -} +vim.pack.add({ + gh("nvim-lualine/lualine.nvim"), +}) + +require("lualine").setup() diff --git a/nvim/lua/plugins/neo-tree.lua b/nvim/lua/plugins/neo-tree.lua deleted file mode 100644 index db38ff2..0000000 --- a/nvim/lua/plugins/neo-tree.lua +++ /dev/null @@ -1,21 +0,0 @@ -return { - "nvim-neo-tree/neo-tree.nvim", - branch = "v3.x", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "MunifTanjim/nui.nvim", - }, - keys = { - { "tt", "Neotree toggle", desc = "NeoTree toggle" }, - { "tr", "Neotree reveal", desc = "NeoTree reveal" }, - }, - config = function() - require("neo-tree").setup({ - window = { - position = "left", - width = 50, - }, - }) - end -} diff --git a/nvim/lua/plugins/neotree.lua b/nvim/lua/plugins/neotree.lua new file mode 100644 index 0000000..e117998 --- /dev/null +++ b/nvim/lua/plugins/neotree.lua @@ -0,0 +1,16 @@ +vim.pack.add({ + { + src = gh("nvim-neo-tree/neo-tree.nvim"), + version = vim.version.range("3") + }, + gh("nvim-lua/plenary.nvim"), + gh("MunifTanjim/nui.nvim"), + gh("nvim-tree/nvim-web-devicons"), +}) + +require("neo-tree").setup({ + window = { + position = "left", + width = 50, + }, +}) diff --git a/nvim/lua/plugins/sonarlint.lua b/nvim/lua/plugins/sonarlint.lua index 8f7c2cf..1b8ddc7 100644 --- a/nvim/lua/plugins/sonarlint.lua +++ b/nvim/lua/plugins/sonarlint.lua @@ -1,38 +1,33 @@ -return { - { - url = "https://gitlab.com/schrieveslaach/sonarlint.nvim", - lazy = true, - ft = {"java", "go", "html", "python", "php"}, - config = function() - require('sonarlint').setup({ - server = { - cmd = { - 'sonarlint-ls', - '-stdio', - '-analyzers', - "/usr/share/java/sonarlint-ls/analyzers/sonarjava.jar", - "/usr/share/java/sonarlint-ls/analyzers/sonargo.jar", - "/usr/share/java/sonarlint-ls/analyzers/sonarhtml.jar", - "/usr/share/java/sonarlint-ls/analyzers/sonarpython.jar", - "/usr/share/java/sonarlint-ls/analyzers/sonarphp.jar", - }, - settings = { - sonarlint = { - test = "test", - disableTelemetry = true, - focusOnNewCode = true, - showAnalyzerLogs = true, - }, - }, - }, - filetypes = { - 'java', - 'go', - 'html', - 'python', - "php" - }, - }) - end - } -} +vim.pack.add({ + gl("schrieveslaach/sonarlint.nvim"), +}) + +require('sonarlint').setup({ + server = { + cmd = { + 'sonarlint-ls', + '-stdio', + '-analyzers', + "/usr/share/java/sonarlint-ls/analyzers/sonarjava.jar", + "/usr/share/java/sonarlint-ls/analyzers/sonargo.jar", + "/usr/share/java/sonarlint-ls/analyzers/sonarhtml.jar", + "/usr/share/java/sonarlint-ls/analyzers/sonarpython.jar", + "/usr/share/java/sonarlint-ls/analyzers/sonarphp.jar", + }, + settings = { + sonarlint = { + test = "test", + disableTelemetry = true, + focusOnNewCode = true, + showAnalyzerLogs = true, + }, + }, + }, + filetypes = { + 'java', + 'go', + 'html', + 'python', + "php" + }, +}) diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index 3675166..a1d9264 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -1,26 +1,12 @@ -return { - 'nvim-telescope/telescope.nvim', - branch = '0.1.x', - lazy = false, - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-telescope/telescope-ui-select.nvim', - }, - keys = { - { "", "Telescope" }, - { "", "Telescope buffers", desc = "Find luffers" }, - { "", "Telescope git_files", desc = "Find files" }, - { "", "Telescope lsp_document_symbols", desc = "Find symbols" }, - { "", "lua require('telescope.builtin').diagnostics({severity_limit='WARN'})", desc = "Show errors and warnings" }, - }, - config = function() - local t = require("telescope") - t.setup({ - defaults = { - preview = false, - }, - }) +vim.pack.add({ + gh('nvim-telescope/telescope.nvim'), + gh('nvim-telescope/telescope-ui-select.nvim'), + gh("nvim-lua/plenary.nvim"), +}) - t.load_extension("ui-select") - end -} +require("telescope").setup({ + defaults = { + preview = false, + }, +}) +require("telescope").load_extension("ui-select") diff --git a/nvim/lua/plugins/todo-comments.lua b/nvim/lua/plugins/todo-comments.lua index 8e8d8ee..439993e 100644 --- a/nvim/lua/plugins/todo-comments.lua +++ b/nvim/lua/plugins/todo-comments.lua @@ -1,8 +1,6 @@ -return { - "folke/todo-comments.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - }, - opts = { - }, -} +vim.pack.add({ + gh("folke/todo-comments.nvim"), + gh("nvim-lua/plenary.nvim"), +}) + +require("todo-comments").setup() diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua index 81e10a4..1b33116 100644 --- a/nvim/lua/plugins/treesitter.lua +++ b/nvim/lua/plugins/treesitter.lua @@ -1,57 +1,75 @@ -return { - "nvim-treesitter/nvim-treesitter", - event = { - "BufReadPre", - "BufNewFile", - }, - build = ":TSUpdate", - config = function() - local treesitter = require("nvim-treesitter.configs") +vim.pack.add({ + gh("neovim-treesitter/nvim-treesitter"), +}) - treesitter.setup({ - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - indent = { - enable = true - }, - autotag = { - enable = true, - }, - ensure_installed = { - "json", - "javascript", - "yaml", - "html", - "css", - "markdown", - "markdown_inline", - "bash", - "lua", - "vim", - "gitignore", - "go", - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - node_incremental = "", - scope_incremental = false, - node_decremental = "", - }, - }, - rainbow = { - enable = true, - disable = { "html" }, - extended_mode = false, - max_file_lines = nil, - }, - context_commentstring = { - enable = true, - enable_autocmd = false, - }, - }) - end, +--require("nvim-treesitter.configs").setup({ +-- highlight = { +-- enable = true, +-- additional_vim_regex_highlighting = false, +-- }, +-- indent = { +-- enable = true +-- }, +-- autotag = { +-- enable = true, +-- }, +-- ensure_installed = { +-- "json", +-- "javascript", +-- "yaml", +-- "html", +-- "http", +-- "css", +-- "markdown", +-- "markdown_inline", +-- "bash", +-- "lua", +-- "vim", +-- "gitignore", +-- "go", +-- }, +-- incremental_selection = { +-- enable = true, +-- keymaps = { +-- init_selection = "", +-- node_incremental = "", +-- scope_incremental = false, +-- node_decremental = "", +-- }, +-- }, +-- rainbow = { +-- enable = true, +-- disable = { "html" }, +-- extended_mode = false, +-- max_file_lines = nil, +-- }, +-- context_commentstring = { +-- enable = true, +-- enable_autocmd = false, +-- }, +--}) +require("nvim-treesitter").install { + "fish", + "lua", + "gitcommit", + "gitignore", + "http", + "html", + "css", + "javascript", + "json", + "yaml", + "markdown", + "markdown_inline", + "go", } + +vim.api.nvim_create_autocmd("FileType", { + pattern = { "http", "html", "go" }, + callback = function() + vim.treesitter.start() + --vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" + --vim.wo.foldmethod = "expr" + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end, +}) diff --git a/nvim/lua/plugins/trouble.lua b/nvim/lua/plugins/trouble.lua index 562539c..2cb625b 100644 --- a/nvim/lua/plugins/trouble.lua +++ b/nvim/lua/plugins/trouble.lua @@ -1,87 +1,4 @@ -return { - "folke/trouble.nvim", - opts = {}, -- for default options, refer to the configuration section for custom setup. - cmd = "Trouble", - keys = { - { - "xx", - "Trouble diagnostics toggle", - desc = "Diagnostics (Trouble)", - }, - { - "xX", - "Trouble diagnostics toggle filter.buf=0", - desc = "Buffer Diagnostics (Trouble)", - }, - { - "xe", - "Trouble diagnostics filter.severity=vim.diagnostic.severity.ERROR", - desc = "Error Diagnostics (Trouble)", - }, - { - "xE", - "Trouble diagnostics filter.buf=0 filter.severity=vim.diagnostic.severity.ERROR", - desc = "Error Diagnostics (Trouble)", - }, - { - "xw", - "Trouble diagnostics filter.severity=vim.diagnostic.severity.WARN", - desc = "Warning Diagnostics (Trouble)", - }, - { - "xW", - "Trouble diagnostics filter.buf=0 filter.severity=vim.diagnostic.severity.WARN", - desc = "Warning Diagnostics (Trouble)", - }, - { - "xi", - "Trouble diagnostics filter.severity=vim.diagnostic.severity.INFO", - desc = "Info Diagnostics (Trouble)", - }, - { - "xI", - "Trouble diagnostics filter.buf=0 filter.severity=vim.diagnostic.severity.INFO", - desc = "Info Diagnostics (Trouble)", - }, - { - "xh", - "Trouble diagnostics filter.severity=vim.diagnostic.severity.HINT", - desc = "Info Diagnostics (Trouble)", - }, - { - "xH", - "Trouble diagnostics filter.buf=0 filter.severity=vim.diagnostic.severity.HINT", - desc = "Info Diagnostics (Trouble)", - }, - { - "xt", - "Trouble todo", - desc = "TODOs (Trouble)", - }, - { - "xT", - "Trouble todo filter.buf=0", - desc = "TODOs (Trouble)", - }, - { - "cs", - "Trouble symbols toggle focus=false", - desc = "Symbols (Trouble)", - }, - { - "cl", - "Trouble lsp toggle focus=false win.position=right", - desc = "LSP Definitions / references / ... (Trouble)", - }, - { - "xL", - "Trouble loclist toggle", - desc = "Location List (Trouble)", - }, - { - "xQ", - "Trouble qflist toggle", - desc = "Quickfix List (Trouble)", - }, - }, -} +vim.pack.add({ + gh("folke/trouble.nvim"), + gh("nvim-tree/nvim-web-devicons"), +}) diff --git a/nvim/lua/plugins/typos.lua b/nvim/lua/plugins/typos.lua new file mode 100644 index 0000000..b4b7bfc --- /dev/null +++ b/nvim/lua/plugins/typos.lua @@ -0,0 +1,11 @@ +vim.lsp.config("typos_lsp", { + settings = { + filetypes = { + 'java', + 'go' + }, + }, + init_options = { + diagnosticSeverity = "Hint", + } +}) diff --git a/nvim/lua/user/bindings.lua b/nvim/lua/user/bindings.lua new file mode 100644 index 0000000..1eee88d --- /dev/null +++ b/nvim/lua/user/bindings.lua @@ -0,0 +1,77 @@ +vim.g.mapleader = " " + +-- Navigation +vim.keymap.set('n', 'gb', ':bn') +vim.keymap.set('n', 'gB', ':bp') +vim.keymap.set('n', 'g#', ':b#') +vim.keymap.set("n", "tt", "Neotree toggle") +vim.keymap.set("n", "tr", "Neotree reveal") +vim.keymap.set("n", "", "Telescope") +vim.keymap.set("n", "", "Telescope buffers") +vim.keymap.set("n", "", "Telescope git_files") +vim.keymap.set("n", "", "Telescope lsp_document_symbols") +vim.keymap.set("n", "", "lua require('telescope.builtin').diagnostics({severity_limit='WARN'})") + +-- Terminal mode +vim.keymap.set('t', '', '', { noremap = true}) + +-- LSP +vim.keymap.set("n", "e", vim.diagnostic.open_float) +vim.keymap.set("n", "[d", vim.diagnostic.goto_prev) +vim.keymap.set("n", "]d", vim.diagnostic.goto_next) +vim.keymap.set("n", "q", vim.diagnostic.setloclist) +vim.keymap.set("n", "gD", vim.lsp.buf.declaration) +vim.keymap.set("n", "gd", vim.lsp.buf.definition) +vim.keymap.set("n", "K", vim.lsp.buf.hover) +vim.keymap.set("n", "gi", vim.lsp.buf.implementation) +vim.keymap.set("n", "", vim.lsp.buf.signature_help) +vim.keymap.set("n", "D", vim.lsp.buf.type_definition) +vim.keymap.set("n", "rn", vim.lsp.buf.rename) +vim.keymap.set("n", "ca", vim.lsp.buf.code_action) +vim.keymap.set("n", "gr", vim.lsp.buf.references) +vim.keymap.set("n", "f", function() vim.lsp.buf.format { async = true } end) +vim.keymap.set("n", "xx", function() require('trouble').toggle({mode="diagnostics"}) end) +vim.keymap.set("n", "xX", function() require('trouble').toggle({mode="diagnostics", filter={buf=0}}) end) +vim.keymap.set("n", "xe", function() require('trouble').toggle({mode="diagnostics", filter={severity=vim.diagnostic.severity.ERROR}}) end) +vim.keymap.set("n", "xE", function() require('trouble').toggle({mode="diagnostics", filter={severity=vim.diagnostic.severity.ERROR, buf=0}}) end) +vim.keymap.set("n", "xw", function() require('trouble').toggle({mode="diagnostics", filter={severity=vim.diagnostic.severity.WARN}}) end) +vim.keymap.set("n", "xW", function() require('trouble').toggle({mode="diagnostics", filter={severity=vim.diagnostic.severity.WARN, buf=0}}) end) +vim.keymap.set("n", "xi", function() require('trouble').toggle({mode="diagnostics", filter={severity=vim.diagnostic.severity.INFO}}) end) +vim.keymap.set("n", "xI", function() require('trouble').toggle({mode="diagnostics", filter={severity=vim.diagnostic.severity.INFO, buf=0}}) end) +vim.keymap.set("n", "xh", function() require('trouble').toggle({mode="diagnostics", filter={severity=vim.diagnostic.severity.HINT}}) end) +vim.keymap.set("n", "xH", function() require('trouble').toggle({mode="diagnostics", filter={severity=vim.diagnostic.severity.HINT, buf=0}}) end) +vim.keymap.set("n", "xt", function() require('trouble').toggle({mode="todo"}) end) +vim.keymap.set("n", "xT", function() require('trouble').toggle({mode="todo", filter={buf=0}}) end) +vim.keymap.set("n", "cs", function() require('trouble').toggle({mode="symbols"}) end) +vim.keymap.set("n", "cl", function() require('trouble').toggle({mode="lsp", win={position="right"}}) end) +vim.keymap.set("n", "xL", function() require('trouble').toggle({mode="loclist"}) end) +vim.keymap.set("n", "xQ", function() require('trouble').toggle({mode="qflist"}) end) + +-- DAP +vim.keymap.set("n", "", function() require("dap").continue() end) +vim.keymap.set("n", "", function() require("dap").step_over() end) +vim.keymap.set("n", "", function() require("dap").step_into() end) +vim.keymap.set("n", "", function() require("dap").step_out() end) +vim.keymap.set("n", "b", function() require("dap").toggle_breakpoint() end) +vim.keymap.set({"n", "v"}, "d", "") +vim.keymap.set("n", "dB", function() require("dap").set_breakpoint(vim.fn.input('Breakpoint condition: ')) end) +vim.keymap.set("n", "db", function() require("dap").toggle_breakpoint() end) +vim.keymap.set("n", "dc", function() require("dap").continue() end) +vim.keymap.set("n", "da", function() require("dap").continue({ before = get_args }) end) +vim.keymap.set("n", "dC", function() require("dap").run_to_cursor() end) +vim.keymap.set("n", "dg", function() require("dap").goto_() end) +vim.keymap.set("n", "di", function() require("dap").step_into() end) +vim.keymap.set("n", "dj", function() require("dap").down() end) +vim.keymap.set("n", "dk", function() require("dap").up() end) +vim.keymap.set("n", "dl", function() require("dap").run_last() end) +vim.keymap.set("n", "do", function() require("dap").step_out() end) +vim.keymap.set("n", "dO", function() require("dap").step_over() end) +vim.keymap.set("n", "dp", function() require("dap").pause() end) +vim.keymap.set("n", "dr", function() require("dap").repl.toggle() end) +vim.keymap.set("n", "ds", function() require("dap").session() end) +vim.keymap.set("n", "dt", function() require("dap").terminate() end) +vim.keymap.set("n", "dw", function() require("dap.ui.widgets").hover() end) +vim.keymap.set("n", "df", function() require('jdtls').test_class() end) +vim.keymap.set("n", "dn", function() require('jdtls').test_nearest_method() end) +vim.keymap.set("n", "du", function() require("dapui").toggle({ }) end) +vim.keymap.set({"n", "v"}, "de", function() require("dapui").eval() end) diff --git a/nvim/lua/user/dap.lua b/nvim/lua/user/dap.lua new file mode 100644 index 0000000..07c22e8 --- /dev/null +++ b/nvim/lua/user/dap.lua @@ -0,0 +1,21 @@ +local dap = require("dap") + +dap.configurations.java = {{ + type = 'java', + request = 'attach', + name = 'Debug (Attach) port 5005', + hostName = '127.0.0.1', + port = 5005, +},{ + type = 'java', + request = 'attach', + name = 'Debug (Attach) port 5006', + hostName = '127.0.0.1', + port = 5006, +},{ + type = 'java', + request = 'attach', + name = 'Debug (Attach) port 5105', + hostName = '127.0.0.1', + port = 5105, +}} diff --git a/nvim/lua/user/lsp.lua b/nvim/lua/user/lsp.lua new file mode 100644 index 0000000..174bfda --- /dev/null +++ b/nvim/lua/user/lsp.lua @@ -0,0 +1,69 @@ +--vim.lsp.inlay_hint.enable() +vim.diagnostic.config({ + virtual_text = true, + --virtual_lines = true, + --virtual_lines = { + -- current_line = true, + --}, + severity_sort = true, +}) +vim.opt.completeopt = { "menuone", "noselect", "popup", "fuzzy" } + +vim.lsp.enable('html') +vim.lsp.enable('cssls') +vim.lsp.enable('jsonls') +vim.lsp.enable('typos_lsp') +-- Go +vim.lsp.config("gopls", { + settings = { + gopls = { + gofumpt = true, + staticcheck = true, + analyses = { + unusedparams = true, + unusedresult = true, + unusedwrite = true, + unusedvariable = true, + useany = true, + fieldalignment = false, + nilness = true, + shadow = true, + }, + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + codelenses = { + gc_details = true, + generate = true, + regenerate_cgo = true, + tidy = true, + upgrade_dependency = true, + vendor = true, + }, + }, + }, +}) +vim.api.nvim_create_autocmd({"BufWritePre"}, { + pattern = "*.go", + callback = function() + local params = vim.lsp.util.make_range_params() + params.context = {only = {"source.organizeImports"}} + local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params) + for cid, res in pairs(result or {}) do + for _, r in pairs(res.result or {}) do + if r.edit then + local enc = (vim.lsp.get_client_by_id(cid) or {}).offset_encoding or "utf-16" + vim.lsp.util.apply_workspace_edit(r.edit, enc) + end + end + end + vim.lsp.buf.format({async = false}) + end +}) +vim.lsp.enable('gopls') diff --git a/nvim/lua/user/options.lua b/nvim/lua/user/options.lua new file mode 100644 index 0000000..f7f5aaf --- /dev/null +++ b/nvim/lua/user/options.lua @@ -0,0 +1,38 @@ +vim.o.wrap = false +vim.o.number = true +vim.o.wildmode = "longest,list" +vim.o.colorcolumn = "120" +vim.o.tabpagemax = 500 +vim.o.scrolloff = 4; + +-- Indentation +vim.o.smartindent = true +vim.o.tabstop = 4 +vim.o.softtabstop = 4 +vim.o.shiftwidth = 4 +vim.o.expandtab = true +vim.o.cursorcolumn = true +vim.o.cursorline = true + +-- Search +vim.o.incsearch = true +vim.o.hlsearch = true +vim.o.ignorecase = true +vim.o.smartcase = true + +-- Whitespaces +vim.o.listchars = "tab:>-,trail:·" +vim.o.list = true + +-- File handling +vim.o.hidden = true + +vim.cmd("syntax enable") +vim.cmd("filetype plugin on") + +-- Colorscheme +vim.cmd("colorscheme gruvbox") + +-- REST +vim.g.rest_nvim = { +} diff --git a/nvim/lua/user/plugins.lua b/nvim/lua/user/plugins.lua new file mode 100644 index 0000000..f330e80 --- /dev/null +++ b/nvim/lua/user/plugins.lua @@ -0,0 +1,19 @@ +gh = function(x) return "https://github.com/" .. x end +gl = function(x) return "https://gitlab.com/" .. x end +cb = function(x) return "https://codeberg.org/" .. x end + +require("plugins.gruvbox") +require("plugins.lualine") +require("plugins.neotree") +require("plugins.gitsigns") +require("plugins.telescope") +require("plugins.trouble") +require("plugins.todo-comments") +require("plugins.treesitter") +require("plugins.lspconfig") +require("plugins.typos") +require("plugins.jdtls") +require("plugins.sonarlint") +require("plugins.dap") +require("plugins.dap-go") +require("plugins.cmp")