diff --git a/nvim/ftplugin/go.lua b/nvim/ftplugin/go.lua new file mode 100644 index 0000000..2ddf1f1 --- /dev/null +++ b/nvim/ftplugin/go.lua @@ -0,0 +1,4 @@ +vim.opt.spell = true +vim.opt.spelllang = "en_us" +vim.opt.colorcolumn = "120" +vim.opt.textwidth = 120 diff --git a/nvim/ftplugin/java.lua b/nvim/ftplugin/java.lua new file mode 100644 index 0000000..2ddf1f1 --- /dev/null +++ b/nvim/ftplugin/java.lua @@ -0,0 +1,4 @@ +vim.opt.spell = true +vim.opt.spelllang = "en_us" +vim.opt.colorcolumn = "120" +vim.opt.textwidth = 120 diff --git a/nvim/ftplugin/mail.vim b/nvim/ftplugin/mail.vim new file mode 100644 index 0000000..8941bcb --- /dev/null +++ b/nvim/ftplugin/mail.vim @@ -0,0 +1,2 @@ +setlocal colorcolumn=72 +setlocal formatoptions+=aw diff --git a/nvim/ftplugin/markdown.lua b/nvim/ftplugin/markdown.lua new file mode 100644 index 0000000..243cfb3 --- /dev/null +++ b/nvim/ftplugin/markdown.lua @@ -0,0 +1,4 @@ +vim.opt.spell = true +vim.opt.spelllang = "en_us" +vim.opt.colorcolumn = "80" +vim.opt.textwidth = 80 diff --git a/nvim/ftplugin/python.lua b/nvim/ftplugin/python.lua new file mode 100644 index 0000000..fddc401 --- /dev/null +++ b/nvim/ftplugin/python.lua @@ -0,0 +1,4 @@ +vim.opt.spell = true +vim.opt.spelllang = "en_us" +vim.opt.colorcolumn = "120" +vim.opt.textwidth = 80 diff --git a/nvim/ftplugin/tex.vim b/nvim/ftplugin/tex.vim new file mode 100644 index 0000000..42db32e --- /dev/null +++ b/nvim/ftplugin/tex.vim @@ -0,0 +1,3 @@ +setlocal wrap +setlocal linebreak +setlocal nonumber diff --git a/vim/init.vim b/nvim/init.vim similarity index 62% rename from vim/init.vim rename to nvim/init.vim index 2de16ba..31bb1cf 100644 --- a/vim/init.vim +++ b/nvim/init.vim @@ -7,14 +7,7 @@ set colorcolumn=120 let $NVIM_TUI_ENABLE_TRUE_COLOR=1 let g:gruvbox_contrast_dark='hard' let g:gruvbox_hls_cursor='red' -colorscheme gruvbox set tabpagemax=500 -let g:airline#extensions#tabline#enabled = 1 -let g:airline#extensions#tabline#show_buffers = 0 -let g:airline#extensions#tabline#show_splits = 0 -let g:airline#extensions#tabline#show_close_button = 0 -let g:airline#extensions#tabline#show_tab_type = 0 -let g:airline#extensions#tabline#tab_nr_type = 1 " Indentation set smartindent @@ -22,6 +15,8 @@ set tabstop=4 set softtabstop=4 set shiftwidth=4 set expandtab +set cursorcolumn +set cursorline " Search set incsearch @@ -36,6 +31,17 @@ set list " Terminal mode :tnoremap +" File handling +set hidden + " Custom shortcuts map gb :bn map gB :bp + +" 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(), + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "buffer" }, + { name = "path" }, + }), + }) + + vim.cmd([[ + set completeopt=menuone,noinsert,noselect + highlight! default link CmpItemKind CmpItemMenuDefault + ]]) + end, +} diff --git a/nvim/lua/plugins/colorscheme.lua b/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..c2b976a --- /dev/null +++ b/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,14 @@ +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 new file mode 100644 index 0000000..c0c9b71 --- /dev/null +++ b/nvim/lua/plugins/dap-go.lua @@ -0,0 +1,9 @@ +return { + "leoluz/nvim-dap-go", + dependencies = { + "mfussenegger/nvim-dap", + }, + config = function() + require('dap-go').setup() + end, +} diff --git a/nvim/lua/plugins/dap-python.lua b/nvim/lua/plugins/dap-python.lua new file mode 100644 index 0000000..7ad395e --- /dev/null +++ b/nvim/lua/plugins/dap-python.lua @@ -0,0 +1,9 @@ +return { + "mfussenegger/nvim-dap-python", + dependencies = { + "mfussenegger/nvim-dap", + }, + config = function() + require('dap-python').setup() + end, +} diff --git a/nvim/lua/plugins/dap-ui.lua b/nvim/lua/plugins/dap-ui.lua new file mode 100644 index 0000000..6121c12 --- /dev/null +++ b/nvim/lua/plugins/dap-ui.lua @@ -0,0 +1,29 @@ +return { + "rcarriga/nvim-dap-ui", + dependencies = { + "nvim-neotest/nvim-nio", + { + "theHamsta/nvim-dap-virtual-text", + opts = {}, + }, + }, + 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 new file mode 100644 index 0000000..c8aa8f4 --- /dev/null +++ b/nvim/lua/plugins/dap.lua @@ -0,0 +1,35 @@ +return { + "mfussenegger/nvim-dap", + 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" }, + }, +} diff --git a/nvim/lua/plugins/gitsigns.lua b/nvim/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..3ca0639 --- /dev/null +++ b/nvim/lua/plugins/gitsigns.lua @@ -0,0 +1,6 @@ +return { + "lewis6991/gitsigns.nvim", + config = function() + require("gitsigns").setup() + end +} diff --git a/nvim/lua/plugins/jdtls.lua b/nvim/lua/plugins/jdtls.lua new file mode 100644 index 0000000..9b0b64f --- /dev/null +++ b/nvim/lua/plugins/jdtls.lua @@ -0,0 +1,83 @@ +return { + "mfussenegger/nvim-jdtls", + dependencies = { + "williamboman/mason.nvim" + }, + ft = "java", + config = function() + local jdtlsConfig = { + cmd = {'jdtls'}, + on_attach = function(client, bufnr) + require('jdtls').setup_dap({hotcodereplace = 'auto'}) + require('jdtls.dap').setup_dap_main_class_configs() + end, + root_dir = vim.fs.dirname(vim.fs.find({'gradlew', '.git', 'mvnw'}, { upward = true })[1]), + init_options = { + bundles = { + vim.fn.expand("$MASON/share/java-debug-adapter/com.microsoft.java.debug.core.jar"), + vim.fn.expand("$MASON/share/java-debug-adapter/com.microsoft.java.debug.plugin.jar"), + }, + }, + java = { + autobuild = { + enabled = true + }, + debug = { + settings = { + hotCodeReplace = 'auto' + }, + }, + }, + settings = { + java = { + autobuild = { + enabled = true + }, + debug = { + settings = { + hotCodeReplace = 'auto' + }, + }, + saveActions = { + organizeImports = true + }, + signatureHelp = { + enabled = false, + description = { + enabled = false + }, + }, + format = { + enable = true, + settings = { + url = "/home/oliver/Dokumente/Gallery Systems/Products/GS Eclipse Formatter Java.xml" + }, + }, + }, + }, + } + + 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, + }} + + require('jdtls').start_or_attach(jdtlsConfig) + end, +} diff --git a/nvim/lua/plugins/lspconfig.lua b/nvim/lua/plugins/lspconfig.lua new file mode 100644 index 0000000..cd69348 --- /dev/null +++ b/nvim/lua/plugins/lspconfig.lua @@ -0,0 +1,46 @@ +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 nvim_lsp = require("lspconfig") + + local protocol = require("vim.lsp.protocol") + + 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 + end, +} diff --git a/nvim/lua/plugins/lualine.lua b/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..473c340 --- /dev/null +++ b/nvim/lua/plugins/lualine.lua @@ -0,0 +1,7 @@ +return { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("lualine").setup() + end, +} diff --git a/nvim/lua/plugins/mason.lua b/nvim/lua/plugins/mason.lua new file mode 100644 index 0000000..e669482 --- /dev/null +++ b/nvim/lua/plugins/mason.lua @@ -0,0 +1,129 @@ +return { + "williamboman/mason.nvim", + enabled = true, + dependencies = { + "williamboman/mason-lspconfig.nvim", + }, + opts = { + ensure_installed = { + "jdtls", + "java-debug-adapter", + "sonarlint-language-server", + "gradle-language-server", + "html-lsp", + "json-lsp", + "typos-lsp" + }, + }, + config = function() + require("mason").setup() + require("mason-lspconfig").setup() + + lspconfig = require "lspconfig" + + -- Gradle + lspconfig.gradle_ls.setup{} + + -- HTML + lspconfig.html.setup{} + + -- JSON + lspconfig.jsonls.setup{} + + -- Go + lspconfig.gopls.setup{ + 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 + }) + + -- Python + lspconfig.pylsp.setup{ + settings = { + pylsp = { + plugins = { + autopep8 = { + enabled = false, + }, + yapf = { + enabled = true, + }, + pylint = { + enabled = false, + }, + pyflakes = { + enabled = true, + }, + pycodestyle = { + enabled = true, + ignore = { + 'E402', + 'W503', + }, + }, + }, + }, + }, + } + + lspconfig.typos_lsp.setup({ + settings = { + filetypes = { + 'java', + 'go' + }, + }, + init_options = { + diagnosticSeverity = "Info", + } + }) + end, +} diff --git a/nvim/lua/plugins/neo-tree.lua b/nvim/lua/plugins/neo-tree.lua new file mode 100644 index 0000000..6c3aac9 --- /dev/null +++ b/nvim/lua/plugins/neo-tree.lua @@ -0,0 +1,17 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + config = function() + require("neo-tree").setup({ + window = { + position = "left", + width = 50, + }, + }) + end +} diff --git a/nvim/lua/plugins/sonarlint.lua b/nvim/lua/plugins/sonarlint.lua new file mode 100644 index 0000000..dd5cc2f --- /dev/null +++ b/nvim/lua/plugins/sonarlint.lua @@ -0,0 +1,44 @@ +return { + { + url = "https://gitlab.com/schrieveslaach/sonarlint.nvim", + lazy = true, + ft = {"java", "go", "html", "python"}, + dependencies = { + "williamboman/mason.nvim" + }, + config = function() + require('sonarlint').setup({ + server = { + cmd = { + 'sonarlint-language-server', + '-stdio', + '-analyzers', + vim.fn.expand("$MASON/share/sonarlint-analyzers/sonarjava.jar"), + vim.fn.expand("$MASON/share/sonarlint-analyzers/sonargo.jar"), + vim.fn.expand("$MASON/share/sonarlint-analyzers/sonarhtml.jar"), + vim.fn.expand("$MASON/share/sonarlint-analyzers/sonarpython.jar"), + }, + settings = { + sonarlint = { + test = "test", + disableTelemetry = true, + focusOnNewCode = true, + showAnalyzerLogs = true, + rules = { + ['java:S1192'] = { level = 'off' }, + ['go:S1192'] = { level = 'off' }, + }, + }, + }, + }, + filetypes = { + 'java', + 'go', + 'html', + 'python', + }, + }) + end + } +} + diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..043cc72 --- /dev/null +++ b/nvim/lua/plugins/telescope.lua @@ -0,0 +1,25 @@ +return { + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + 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" }, + }, + config = function() + local t = require("telescope") + t.load_extension("ui-select") + t.setup({ + defaults = { + preview = false, + layout_config = { + vertical = { + width = 0.5, + }, + }, + }, + }) + end +} diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..5188588 --- /dev/null +++ b/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,57 @@ +return { + "nvim-treesitter/nvim-treesitter", + event = { + "BufReadPre", + "BufNewFile", + }, + build = ":TSUpdate", + config = function() + local treesitter = require("nvim-treesitter.configs") + + 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", + "rust", + }, + 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, +} diff --git a/nvim/lua/plugins/trouble.lua b/nvim/lua/plugins/trouble.lua new file mode 100644 index 0000000..8104147 --- /dev/null +++ b/nvim/lua/plugins/trouble.lua @@ -0,0 +1,52 @@ +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)", + }, + { + "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)", + }, + { + "xe", + "Trouble diagnostics filter.severity=vim.diagnostic.severity.ERROR", + desc = "Error Diagnostics (Trouble)", + }, + { + "xw", + "Trouble diagnostics filter.severity=vim.diagnostic.severity.WARN", + desc = "Warning Diagnostics (Trouble)", + }, + { + "xi", + "Trouble diagnostics filter.severity=vim.diagnostic.severity.INFO", + desc = "Info Diagnostics (Trouble)", + }, + }, +} diff --git a/vim/filetype.vim b/vim/filetype.vim deleted file mode 100644 index c478e8c..0000000 --- a/vim/filetype.vim +++ /dev/null @@ -1,29 +0,0 @@ -augroup filetypedetect - " Mail - autocmd BufRead,BufNewFile /tmp/evo* setfiletype mail - autocmd FileType mail setlocal colorcolumn=72 - autocmd FileType mail setlocal formatoptions+=aw -augroup END - - -" Break lines for tex-files -augroup WrapLineInTeXFile - autocmd! - autocmd FileType tex setlocal wrap - autocmd FileType tex setlocal linebreak - autocmd FileType tex setlocal nonumber -augroup END - -augroup SpellCheck - autocmd! - autocmd FileType go setlocal spell spelllang=en_us - autocmd FileType java setlocal spell spelllang=en_us - autocmd FileType markdown setlocal spell spelllang=en_us -augroup END - -augroup ColorColumn - autocmd! - autocmd FileType go setlocal colorcolumn=120 - autocmd FileType java setlocal colorcolumn=120 - autocmd FileType markdown setlocal colorcolumn=80 -augroup END diff --git a/vim/vimrc b/vim/vimrc deleted file mode 100644 index 63e45e4..0000000 --- a/vim/vimrc +++ /dev/null @@ -1,30 +0,0 @@ -filetype plugin on -syntax on -set number -set nowrap -set wildmode=longest,list -set colorcolumn=80 -let g:airline#extensions#tabline#enabled = 1 -let g:airline#extensions#tabline#show_buffers = 0 -let g:airline#extensions#tabline#show_splits = 0 -let g:airline#extensions#tabline#show_close_button = 0 -let g:airline#extensions#tabline#show_tab_type = 0 -let g:airline#extensions#tabline#tab_nr_type = 1 - -" Indentation -set smartindent -set tabstop=4 -set softtabstop=4 -set shiftwidth=4 -set expandtab - -" Search -set incsearch -set hlsearch -set ignorecase -set smartcase - -" Whitespaces -set listchars=tab:>-,trail:ยท -set list -:nnoremap :let _s=@/:%s/\s\+$//e:let @/=_s:nohl