From b426f25aef1f2be2b482bf0b256733eba0b1c5aa Mon Sep 17 00:00:00 2001 From: Max Bossing Date: Tue, 22 Jul 2025 17:06:33 +0200 Subject: smh so cool shit --- nvim/init.lua | 119 +++------------------------------------- nvim/lua/keymap.lua | 19 +++++++ nvim/lua/lsp.lua | 55 +++++++++++++++++++ nvim/lua/options.lua | 35 ++++++++++++ nvim/lua/plugins.lua | 92 +++++++++++++++++++++++++++++++ nvim/lua/plugins/lualine.lua | 8 +++ nvim/lua/plugins/oil.lua | 1 + nvim/lua/plugins/telescope.lua | 9 +++ nvim/lua/plugins/treesitter.lua | 3 + 9 files changed, 230 insertions(+), 111 deletions(-) create mode 100644 nvim/lua/keymap.lua create mode 100644 nvim/lua/lsp.lua create mode 100644 nvim/lua/options.lua create mode 100644 nvim/lua/plugins.lua create mode 100644 nvim/lua/plugins/lualine.lua create mode 100644 nvim/lua/plugins/oil.lua create mode 100644 nvim/lua/plugins/telescope.lua create mode 100644 nvim/lua/plugins/treesitter.lua diff --git a/nvim/init.lua b/nvim/init.lua index d911177..2c5506b 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,117 +1,14 @@ -vim.g.loaded_netrw = 1 -vim.g.loaded_netrwPlugin = 1 +require('plugins') -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) +require('options') -require("lazy").setup({ - - -- Color Scheme - "folke/tokyonight.nvim", - - -- Syntax highlighting - 'nvim-treesitter/nvim-treesitter', - - -- Status line - 'nvim-lualine/lualine.nvim', - - -- Git - 'airblade/vim-gitgutter', - - -- File System - 'stevearc/oil.nvim', - - { - 'OXY2DEV/markview.nvim', - lazy = false, - priority = 49, - - }, - - -- Telescope - { - 'nvim-telescope/telescope.nvim', - tag = '0.1.5', - dependencies = { - 'nvim-lua/plenary.nvim', - 'sharkdp/fd', - { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, - } - }, - - -- Icons - { - "echasnovski/mini.icons", - lazy = true, - init = function() - package.preload["nvim-web-devicons"] = function() - require("mini.icons").mock_nvim_web_devicons() - return package.loaded["nvim-web-devicons"] - end - end, - }, -}) - - - --- Colorscheme vim.cmd [[colorscheme tokyonight-moon]] -vim.opt.termguicolors = true -vim.o.background = "dark" - --- Map leader to space -vim.g.mapleader = ' ' - --- Tabs sind für lutscher -vim.opt.tabstop = 2 -vim.opt.shiftwidth = 2 -vim.o.expandtab = true - --- Numbers on the side -vim.wo.number = true -vim.wo.relativenumber = true -vim.o.ruler = true --- Show something in the command line not sure -vim.o.showcmd = true - --- reload config without restart -vim.keymap.set('n', 'r', ':so %') - --- Lualine setup -require('lualine').setup { - options = { - icons_enabled = true, - theme = 'auto', - section_separators = { left = '', right = '' }, - component_separators = { left = '', right = '' } - }, -} - --- Treesitter setup -require('nvim-treesitter.configs').setup { - highlight = { enable = true } -} - --- Telescope setup -local telescope = require('telescope') -telescope.load_extension('fzf') -vim.keymap.set('n', 'tf', ':Telescope find_files') -- file search -vim.keymap.set('n', 'tb', ':Telescope buffers') -- buffer peak -vim.keymap.set('n', 'th', ':Telescope help_tags') -- help menu -vim.keymap.set('n', 'tt', ':Telescope treesitter ') -- treesitter symbol menu -vim.keymap.set('n', 'tp', ':Telescope builtin') -- picker picker lmao - -require('oil').setup() +require('lsp') +require('plugins/lualine') +require('plugins/telescope') +require('plugins/oil') +require('plugins/treesitter') +require('keymap') diff --git a/nvim/lua/keymap.lua b/nvim/lua/keymap.lua new file mode 100644 index 0000000..0d4ce23 --- /dev/null +++ b/nvim/lua/keymap.lua @@ -0,0 +1,19 @@ +-- vim-fugitive +vim.keymap.set('n', 'gs', ':Git') + +-- move code in visual-line mode +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +-- Paste while yanking into void (paste without loosing register) +vim.keymap.set("x", "p", [["_dP]]) + +-- directly yank into system clipboard +vim.keymap.set({ "n", "v" }, "y", [["+y]]) +vim.keymap.set("n", "Y", [["+Y]]) + +-- delete while yanking into void +vim.keymap.set({ "n", "v" }, "d", "\"_d") + + +vim.keymap.set("n", "-", "Oil") diff --git a/nvim/lua/lsp.lua b/nvim/lua/lsp.lua new file mode 100644 index 0000000..b7fad3e --- /dev/null +++ b/nvim/lua/lsp.lua @@ -0,0 +1,55 @@ +require('mason').setup() + +vim.lsp.enable('lua-language-server') + +local bufnr = vim.api.nvim_get_current_buf() +vim.keymap.set('n', 'a', + function() + vim.cmd.RustLsp('codeAction') + end, + { silent = true, buffer = bufnr } +) + +vim.keymap.set('n', 'K', + function() + vim.cmd.RustLsp({'hover', 'actions'}) + end, + { silent = true, buffer = bufnr } +) + + +local cmp = require('cmp') +cmp.setup({ + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.select_prev_item({behavior = cmp.SelectBehavior.Select}), + [''] = cmp.mapping.select_next_item({behavior = cmp.SelectBehavior.Select}), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + }, { + { name = 'buffer' }, + }) +}) + +cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } +}) + +cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }), + matching = { disallow_symbol_nonprefix_matching = false } +}) + +require('lsp_signature').setup() diff --git a/nvim/lua/options.lua b/nvim/lua/options.lua new file mode 100644 index 0000000..a7cce04 --- /dev/null +++ b/nvim/lua/options.lua @@ -0,0 +1,35 @@ +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +vim.opt.termguicolors = true +vim.o.background = "dark" + +vim.opt.colorcolumn = "80" +vim.opt.updatetime = 50 + +-- Map leader to space +vim.g.mapleader = ' ' + +-- Tabs sind für lutscher +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 +vim.o.expandtab = true +vim.opt.smartindent = true + +-- QoL for search +vim.opt.hlsearch = false +vim.opt.incsearch = true + +-- Scrolling +vim.opt.scrolloff = 10 +vim.opt.signcolumn = "yes" +vim.opt.isfname:append('@-@') + +-- Numbers on the side +vim.wo.number = true +vim.wo.relativenumber = true +vim.o.ruler = true + +-- Show something in the command line not sure +vim.o.showcmd = true + diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua new file mode 100644 index 0000000..7a7353d --- /dev/null +++ b/nvim/lua/plugins.lua @@ -0,0 +1,92 @@ +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) + +require("lazy").setup({ + + -- Color Scheme + "folke/tokyonight.nvim", + + -- Syntax highlighting + 'nvim-treesitter/nvim-treesitter', + + -- Status line + 'nvim-lualine/lualine.nvim', + + -- Git + 'airblade/vim-gitgutter', + + -- File System + 'stevearc/oil.nvim', + 'benomahony/oil-git.nvim', + + -- non-linear undo history + 'mbbill/undotree', + + -- Git + 'tpope/vim-fugitive', + + -- Comments + "tpope/vim-commentary", + + -- Some lsp shit + 'mason-org/mason.nvim', + + { + 'OXY2DEV/markview.nvim', + lazy = false, + priority = 49, + + }, + + -- Telescope + { + 'nvim-telescope/telescope.nvim', + tag = '0.1.5', + dependencies = { + 'nvim-lua/plenary.nvim', + 'sharkdp/fd', + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, + } + }, + + -- Icons + { + "echasnovski/mini.icons", + lazy = true, + init = function() + package.preload["nvim-web-devicons"] = function() + require("mini.icons").mock_nvim_web_devicons() + return package.loaded["nvim-web-devicons"] + end + end, + }, + + { + 'mrcjkb/rustaceanvim', + version = '^6', -- Recommended + lazy = false, -- This plugin is already lazy + }, + + {"hrsh7th/nvim-cmp"}, + {"hrsh7th/cmp-buffer"}, + {"hrsh7th/cmp-path"}, + {"hrsh7th/cmp-nvim-lsp"}, + {"hrsh7th/cmp-nvim-lua"}, + + { + "ray-x/lsp_signature.nvim", + event = InsertEnter + }, + +}) + diff --git a/nvim/lua/plugins/lualine.lua b/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..2356803 --- /dev/null +++ b/nvim/lua/plugins/lualine.lua @@ -0,0 +1,8 @@ +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'auto', + section_separators = { left = '', right = '' }, + component_separators = { left = '', right = '' } + }, +} diff --git a/nvim/lua/plugins/oil.lua b/nvim/lua/plugins/oil.lua new file mode 100644 index 0000000..d24cfbb --- /dev/null +++ b/nvim/lua/plugins/oil.lua @@ -0,0 +1 @@ +require('oil').setup() diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..4744a68 --- /dev/null +++ b/nvim/lua/plugins/telescope.lua @@ -0,0 +1,9 @@ +local telescope = require('telescope') +telescope.load_extension('fzf') +vim.keymap.set('n', 'tf', ':Telescope find_files') -- file search +vim.keymap.set('n', 'tb', ':Telescope buffers') -- buffer peak +vim.keymap.set('n', 'th', ':Telescope help_tags') -- help menu +vim.keymap.set('n', 'tt', ':Telescope treesitter ') -- treesitter symbol menu +vim.keymap.set('n', 'tp', ':Telescope builtin') -- picker picker lmao + + diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..06536f3 --- /dev/null +++ b/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,3 @@ +require('nvim-treesitter.configs').setup { + highlight = { enable = true } +} -- cgit v1.0