commit d40ca7274ad5cee70eb151dd2c07d66e17f4021d Author: Tim Date: Wed Aug 21 22:20:18 2024 +0200 initial commit diff --git a/after/plugin/remaps.lua b/after/plugin/remaps.lua new file mode 100644 index 0000000..2d33186 --- /dev/null +++ b/after/plugin/remaps.lua @@ -0,0 +1,11 @@ +local builtin = require('telescope.builtin') +vim.keymap.set('n', 'ff', builtin.find_files, {}) +vim.keymap.set('n', 'fg', builtin.live_grep, {}) +vim.keymap.set('n', 'fb', builtin.buffers, {}) +vim.keymap.set('n', 'fh', builtin.help_tags, {}) + + +vim.keymap.set('n', 'q', ':q', {}) +vim.keymap.set('n', 'w', ':w', {}) + +vim.keymap.set('n', 'c', ':noh', {}) diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..c8de22d --- /dev/null +++ b/init.lua @@ -0,0 +1,48 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + + +vim.g.mapleader = " " + +require("lazy").setup("plugins") + +-- line numbers +vim.opt.rnu = true +vim.opt.nu = true + +-- search +vim.opt.smartcase = true +vim.opt.ignorecase = true + +-- tabstops +vim.opt.ts = 2 +vim.opt.sw = 2 + +--folding +vim.opt.foldmethod = "indent" +vim.opt.foldlevel = 99 + +--clipboard +vim.opt.clipboard = "unnamedplus" + +-- colortheme +vim.opt.termguicolors = true + +vim.api.nvim_create_autocmd('TextYankPost', { + -- group = vim.api.nvim_create_augroup('highlight_yank' ), + desc = 'Hightlight selection on yank', + pattern = '*', + callback = function() + vim.highlight.on_yank { higroup = 'IncSearch', timeout = 500 } + end, +}) diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..9f4c310 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,24 @@ +{ + "LuaSnip": { "branch": "master", "commit": "50fcf17db7c75af80e6b6109acfbfb4504768780" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "conform.nvim": { "branch": "master", "commit": "069e971295a34a810484b7b2ef54b3c735214181" }, + "copilot.vim": { "branch": "release", "commit": "1dcaf72099b436b5832d6117d9cd7a4a098a8d77" }, + "everforest": { "branch": "master", "commit": "9dbd4d1c3255ed801e515f2ed388f4c6ceb62f6e" }, + "lazy.nvim": { "branch": "main", "commit": "eb4957442e3182f051b0ae11da32e06d22c190e3" }, + "lsp-zero.nvim": { "branch": "v3.x", "commit": "16de3b18c5f7b6230d89b8e64ce9a4801b6f8d08" }, + "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "8db12610bcb7ce67013cfdfaba4dd47a23c6e851" }, + "mason.nvim": { "branch": "main", "commit": "0950b15060067f752fde13a779a994f59516ce3d" }, + "nvim-cmp": { "branch": "main", "commit": "5260e5e8ecadaf13e6b82cf867a909f54e15fd07" }, + "nvim-comment": { "branch": "main", "commit": "e9ac16ab056695cad6461173693069ec070d2b23" }, + "nvim-jdtls": { "branch": "master", "commit": "40e8494e04c1bcd5dd6c0d0bc187d2d10965017d" }, + "nvim-lspconfig": { "branch": "master", "commit": "92166b89ab4b3d60f24e58170cac53b7141fd032" }, + "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, + "nvim-treesitter": { "branch": "master", "commit": "c5cbd3ec74f6f5ddbac939e6f24b99fe78262b4c" }, + "nvim-ts-autotag": { "branch": "main", "commit": "6eb4120a1aadef07ac312f1c4bc6456712220007" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" }, + "nvim-web-devicons": { "branch": "master", "commit": "b4b302d6ae229f67df7a87ef69fa79473fe788a9" }, + "oil.nvim": { "branch": "master", "commit": "e5312c3a801e7274fa14e6a56aa10a618fed80c3" }, + "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, + "telescope.nvim": { "branch": "master", "commit": "54930e1abfc94409e1bb9266e752ef8379008592" } +} \ No newline at end of file diff --git a/lua/plugins/autotag.lua b/lua/plugins/autotag.lua new file mode 100644 index 0000000..93f2705 --- /dev/null +++ b/lua/plugins/autotag.lua @@ -0,0 +1,5 @@ +return { + 'windwp/nvim-ts-autotag', + lazy = false, + config = true, +} diff --git a/lua/plugins/comment.lua b/lua/plugins/comment.lua new file mode 100644 index 0000000..b2a82fb --- /dev/null +++ b/lua/plugins/comment.lua @@ -0,0 +1,15 @@ +return { + 'terrortylor/nvim-comment', + lazy = false, + config = function() + require('nvim_comment').setup({ + hook = function() + require('ts_context_commentstring.internal').update_commentstring() + end, + }) + end, + dependencies = { + -- To customize commentstring for e.g. svelte files, as the commentstring is depending on cursor position + 'JoosepAlviste/nvim-ts-context-commentstring' + } +} diff --git a/lua/plugins/copilot.lua b/lua/plugins/copilot.lua new file mode 100644 index 0000000..c4d1162 --- /dev/null +++ b/lua/plugins/copilot.lua @@ -0,0 +1,6 @@ +return { + "github/copilot.vim", + config = function() + vim.g.copilot_filetypes = { markdown = true } + end, +} diff --git a/lua/plugins/format.lua b/lua/plugins/format.lua new file mode 100644 index 0000000..f20f42c --- /dev/null +++ b/lua/plugins/format.lua @@ -0,0 +1,26 @@ +return { + 'stevearc/conform.nvim', + lazy = false, + opts = { + notify_on_error = true, + formatters_by_ft = { + svelte = { "prettier" }, + vue = { "prettier" }, + }, + format_on_save = { + lsp_fallback = true, + timeout_ms = 1500, + }, + }, + config = function(_, opts) + local plug = require('conform') + plug.setup(opts) + + -- vim.api.nvim_create_autocmd("BufWritePre", { + -- pattern = "*", + -- callback = function(args) + -- plug.format({ bufnr = args.buf }) + -- end, + -- }) + end, +} diff --git a/lua/plugins/lsp-java.lua b/lua/plugins/lsp-java.lua new file mode 100644 index 0000000..b4aaf79 --- /dev/null +++ b/lua/plugins/lsp-java.lua @@ -0,0 +1,38 @@ +return { + 'mfussenegger/nvim-jdtls', + layz = false, + config = function() + local home = os.getenv('HOME') + local workspace_folder = home .. "/.local/share/eclipse/" .. vim.fn.fnamemodify(root_dir, ":p:h:t") + local config = { + cmd = { + '/usr/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', + '-Xmx1g', + '--add-modules=ALL-SYSTEM', + '--add-opens', 'java.base/java.util=ALL-UNNAMED', + '--add-opens', 'java.base/java.lang=ALL-UNNAMED', + + '-javaagent:/usr/share/java/lombok/lombok.jar', + + '-jar', home .. '/.local/share/jdtls/plugins/org.eclipse.equinox.launcher_1.6.500.v20230717-2134.jar', + '-configuration', home .. '/.local/share/jdtls/config_linux', + + '-data', workspace_folder + }, + root_dir = vim.fs.dirname(vim.fs.find({ 'gradlew', 'mvnw', '.git' }, { upward = true })[1]), + } + + vim.api.nvim_create_autocmd("FileType", { + pattern = "java", + callback = function() + require('jdtls').start_or_attach(config) + end + }) + end, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..48cee6e --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,52 @@ +return { + { + 'williamboman/mason.nvim', + lazy = false, + config = true, + }, + { + 'williamboman/mason-lspconfig.nvim', + lazy = false, + config = function() + local lsp_zero = require('lsp-zero') + + lsp_zero.extend_lspconfig() + + lsp_zero.on_attach(function(_, bufnr) + -- see :help lsp-zero-keybindings + -- to learn the available actions + lsp_zero.default_keymaps({ buffer = bufnr }) + end) + + require('mason-lspconfig').setup { + ensure_installed = { 'rust_analyzer', 'lua_ls', 'kotlin_language_server' }, + handlers = { + lsp_zero.default_setup, + kotlin_language_server = function() + require('lspconfig').kotlin_language_server.setup({ + settings = { kotlin = { compiler = { jvm = { target = "17" } } } } + }) + end, + } } + end, + }, + + { 'VonHeikemen/lsp-zero.nvim' }, + { 'neovim/nvim-lspconfig' }, + { 'hrsh7th/cmp-nvim-lsp' }, + { + 'hrsh7th/nvim-cmp', + lazy = false, + config = function() + local cmp = require('cmp') + + cmp.setup({ + mapping = cmp.mapping.preset.insert({ + -- add Ctrl+z to default keymap from lsp-zero as replacement to Ctrl+y on german keyboard layout + [''] = cmp.mapping.confirm({ select = true }), + }) + }) + end + }, + { 'L3MON4D3/LuaSnip' }, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..5873612 --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,12 @@ +return { + -- status line + 'nvim-lualine/lualine.nvim', + lazy = false, + config = true, + opts = { + options = { + theme = "everforest", + }, + }, + dependencies = { 'nvim-tree/nvim-web-devicons' } +} diff --git a/lua/plugins/maven.lua b/lua/plugins/maven.lua new file mode 100644 index 0000000..9ecafc7 --- /dev/null +++ b/lua/plugins/maven.lua @@ -0,0 +1,4 @@ +return { + -- 'TimsDevCorner/vim-maven-plugin', + -- lazy = false +} diff --git a/lua/plugins/notify.lua b/lua/plugins/notify.lua new file mode 100644 index 0000000..95fe768 --- /dev/null +++ b/lua/plugins/notify.lua @@ -0,0 +1,7 @@ +return { + 'rcarriga/nvim-notify', + lazy = false, + config = function() + vim.notify = require('notify') + end, +} diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua new file mode 100644 index 0000000..4d5488c --- /dev/null +++ b/lua/plugins/oil.lua @@ -0,0 +1,16 @@ +return { + 'stevearc/oil.nvim', + lazy = false, + config = function() + require('oil').setup({ + view_options = { + show_hidden = true, + sort = { + { "type", "asc" }, + { "name", "asc" }, + }, + }, + }) + vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) + end, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..429ad58 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,10 @@ +return { + 'nvim-telescope/telescope.nvim', + tag = '0.1.3', + opts = { + defaults = { + path_display = { "smart" }, + } + }, + dependencies = { 'nvim-lua/plenary.nvim' }, +} diff --git a/lua/plugins/theme-everforest.lua b/lua/plugins/theme-everforest.lua new file mode 100644 index 0000000..97f5c23 --- /dev/null +++ b/lua/plugins/theme-everforest.lua @@ -0,0 +1,7 @@ +return { + "sainnhe/everforest", + priority = 1000, -- make sure to load this before all the other start plugins + config = function() + vim.cmd([[colorscheme everforest]]) + end, +} diff --git a/lua/plugins/theme_tokyonight.lua b/lua/plugins/theme_tokyonight.lua new file mode 100644 index 0000000..746c79f --- /dev/null +++ b/lua/plugins/theme_tokyonight.lua @@ -0,0 +1,15 @@ +return { + -- "folke/tokyonight.nvim", + -- lazy = false, + -- priority = 1000, + -- opts = { + -- style = "moon", + -- on_colors = function(colors) + -- colors.fg_gutter = colors.orange + -- end, + -- }, + -- config = function(_, opts) + -- require('tokyonight').setup(opts) + -- vim.cmd([[colorscheme tokyonight]]) + -- end, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..8ad045d --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,12 @@ +return { + "nvim-treesitter/nvim-treesitter", + config = function() + require("nvim-treesitter.configs").setup { + auto_install = true, + highlight = { + enable = true, + }, + } + vim.cmd([[TSUpdate]]) + end +}