From 27f23d9317a9e7aaa9216a292f081cd459e0f5bd Mon Sep 17 00:00:00 2001 From: Tim Wundenberg Date: Wed, 30 Jul 2025 19:27:21 +0200 Subject: [PATCH] feat: use native nvim functionality --- init.lua | 306 +++++++++++++++++++------------------------------ lazy-lock.json | 22 ---- 2 files changed, 119 insertions(+), 209 deletions(-) delete mode 100644 lazy-lock.json diff --git a/init.lua b/init.lua index 9f1abcb..600a84d 100644 --- a/init.lua +++ b/init.lua @@ -1,197 +1,113 @@ -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.opt.number = true +vim.opt.relativenumber = true +vim.opt.smartcase = true +vim.opt.ignorecase = true +vim.opt.ts = 4 +vim.opt.sw = 0 +vim.opt.foldmethod = "indent" +vim.opt.foldlevel = 99 +vim.opt.clipboard = "unnamedplus" +vim.opt.signcolumn = "yes" +vim.opt.termguicolors = true +vim.pack.add({ + { src = "https://github.com/stevearc/oil.nvim" }, + { src = "https://github.com/echasnovski/mini.pick" }, + { src = "https://github.com/echasnovski/mini.icons" }, + { src = "https://github.com/nvim-treesitter/nvim-treesitter" }, + { src = "https://github.com/neovim/nvim-lspconfig" }, + { src = "https://github.com/sainnhe/everforest" }, + { src = "https://github.com/nvim-lualine/lualine.nvim" }, -require("lazy").setup({ - spec = { - { - 'windwp/nvim-ts-autotag', - lazy = false, - config = true, - }, - { - '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' - } - }, - { - { - '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' }, - handlers = { - lsp_zero.default_setup - } } - 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 - } - }, - { - 'stevearc/conform.nvim', - lazy = false, - opts = { - notify_on_error = true, - formatters_by_ft = { - templ = { "templ" }, - }, - format_on_save = { - lsp_fallback = true, - timeout_ms = 1500, - }, - }, - config = function(_, opts) - local plug = require('conform') - plug.setup(opts) - end, - }, - { - -- status line - 'nvim-lualine/lualine.nvim', - lazy = false, - config = true, - opts = { - options = { - theme = "everforest", - }, - }, - dependencies = { 'nvim-tree/nvim-web-devicons' } - }, - { - 'rcarriga/nvim-notify', - lazy = false, - config = function() - vim.notify = require('notify') - end, - }, - { - '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, - }, - { - 'nvim-telescope/telescope.nvim', - opts = { - defaults = { - path_display = { "smart" }, - file_ignore_patterns = { "node%_modules/.*" } - } - }, - dependencies = { 'nvim-lua/plenary.nvim' }, - }, - { - "sainnhe/everforest", - priority = 1000, -- make sure to load this before all the other start plugins - config = function() - vim.cmd([[colorscheme everforest]]) - end, - }, - { - "nvim-treesitter/nvim-treesitter", - config = function() - require("nvim-treesitter.configs").setup { - auto_install = true, - highlight = { - enable = true, - }, - } - vim.cmd([[TSUpdate]]) - end - } - } }) -vim.g.mapleader = " " +require('lualine').setup({ + options = { + theme = "everforest", + }, +}) --- line numbers -vim.opt.rnu = true -vim.opt.nu = true +vim.cmd([[colorscheme everforest]]) +require('mini.icons').setup() --- search -vim.opt.smartcase = true -vim.opt.ignorecase = true --- tabstops -vim.opt.ts = 4 -vim.opt.sw = 0 +require('oil').setup({ + view_options = { + show_hidden = true, + sort = { + { "type", "asc" }, + { "name", "asc" }, + }, + }, +}) --- folding -vim.opt.foldmethod = "indent" -vim.opt.foldlevel = 99 +-- require("nvim-lspconfig").setup({ inlay_hints = { enabled = true } }) ---clipboard -vim.opt.clipboard = "unnamedplus" +vim.api.nvim_create_autocmd('LspAttach', { + callback = function(ev) + local client = vim.lsp.get_client_by_id(ev.data.client_id) + if client:supports_method('textDocument/completion') then + vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true }) + end --- other -vim.opt.signcolumn = "yes" + if client:supports_method("textDocument/inlayHint") or client.server_capabilities.inlayHintProvider then + vim.lsp.inlay_hint.enable(true, { bufnr = bufnr }) + end + end, +}) +vim.cmd("set completeopt+=menuone,noselect,popup") --- colortheme -vim.opt.termguicolors = true +vim.lsp.config('gopls', { + settings = { + ['gopls'] = { + hints = { + assignVariableTypes = true, + parameterNames = true + } + }, + }, +}) +vim.lsp.enable({ "lua_ls", "gopls" }) + +require "mini.pick".setup() +require "nvim-treesitter.configs".setup({ + auto_install = true, + highlight = { enable = true } +}) + + +-- 'windwp/nvim-ts-autotag', +-- 'terrortylor/nvim-comment', +-- 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' +-- } +-- { +-- 'stevearc/conform.nvim', +-- opts = { +-- notify_on_error = true, +-- formatters_by_ft = { +-- templ = { "templ" }, +-- }, +-- format_on_save = { +-- lsp_fallback = true, +-- timeout_ms = 1500, +-- }, +-- }, +-- config = function(_, opts) +-- local plug = require('conform') +-- plug.setup(opts) +-- end, +-- }, +-- { vim.api.nvim_create_autocmd('TextYankPost', { desc = 'Hightlight selection on yank', @@ -201,8 +117,23 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +vim.api.nvim_create_autocmd('BufWritePre', { + desc = 'Atuformat code on save', + pattern = '*', + callback = function() + vim.lsp.buf.format() + end, +}) + vim.filetype.add({ extension = { templ = "templ" } }) +vim.g.mapleader = " " + +vim.keymap.set('i', '', vim.lsp.completion.get, {}) +vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {}) +vim.keymap.set('n', 'gr', vim.lsp.buf.references, {}) +vim.keymap.set('n', '', vim.lsp.buf.rename, {}) +vim.keymap.set('n', '', vim.lsp.buf.code_action, {}) vim.keymap.set('n', 'q', ':q', {}) vim.keymap.set('n', 'w', ':w', {}) @@ -210,8 +141,9 @@ vim.keymap.set('n', 'c', ':noh', {}) vim.keymap.set('n', 'en', vim.diagnostic.goto_next, {}) vim.keymap.set('n', 'ep', vim.diagnostic.goto_prev, {}) -local telescope = require('telescope.builtin') -vim.keymap.set('n', 'ff', telescope.find_files, {}) -vim.keymap.set('n', 'fg', telescope.live_grep, {}) -vim.keymap.set('n', 'fb', telescope.buffers, {}) -vim.keymap.set('n', 'fh', telescope.help_tags, {}) +vim.keymap.set('n', 'ff', ":Pick files", {}) +-- vim.keymap.set('n', 'fg', telescope.live_grep, {}) +-- vim.keymap.set('n', 'fb', telescope.buffers, {}) +vim.keymap.set('n', 'fh', ":Pick help", {}) + +vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) diff --git a/lazy-lock.json b/lazy-lock.json deleted file mode 100644 index 6bf3a38..0000000 --- a/lazy-lock.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "LuaSnip": { "branch": "master", "commit": "66b5c2707e624dcd2cd3605676c64a2efe47e9d1" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, - "conform.nvim": { "branch": "master", "commit": "973f3cb73887d510321653044791d7937c7ec0fa" }, - "everforest": { "branch": "master", "commit": "f40c2e6c8784c99c57c79edc94cd180e76450222" }, - "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, - "lsp-zero.nvim": { "branch": "v4.x", "commit": "d388e2b71834c826e61a3eba48caec53d7602510" }, - "lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "bb3a17efc797c34c054463174e5522442576ebd8" }, - "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, - "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, - "nvim-comment": { "branch": "main", "commit": "e9ac16ab056695cad6461173693069ec070d2b23" }, - "nvim-lspconfig": { "branch": "master", "commit": "7a88e3024a616e153b8760d64b3541e3a166c27f" }, - "nvim-notify": { "branch": "master", "commit": "a22f5d7ac511c2df2fd3290a9f04c48d5a822e2e" }, - "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, - "nvim-web-devicons": { "branch": "master", "commit": "0422a19d9aa3aad2c7e5cca167e5407b13407a9d" }, - "oil.nvim": { "branch": "master", "commit": "bbad9a76b2617ce1221d49619e4e4b659b3c61fc" }, - "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, - "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" } -}