From d6ad21e502d14f9aa32cd9703d713b7f7f2d8a9d Mon Sep 17 00:00:00 2001 From: Tobias Loft Date: Thu, 3 Apr 2025 10:24:44 +0200 Subject: [PATCH] Adding a neovim confing that is quite nice --- init.lua | 1 + lua/tobias/init.lua | 3 ++ lua/tobias/lazy/colors.lua | 91 ++++++++++++++++++++++++++++++++++ lua/tobias/lazy/init.lua | 8 +++ lua/tobias/lazy/lsp.lua | 52 +++++++++++++++++++ lua/tobias/lazy/telescope.lua | 29 +++++++++++ lua/tobias/lazy/treesitter.lua | 86 ++++++++++++++++++++++++++++++++ lua/tobias/lazy_init.lua | 17 +++++++ lua/tobias/remap.lua | 25 ++++++++++ lua/tobias/set.lua | 13 +++++ 10 files changed, 325 insertions(+) create mode 100644 init.lua create mode 100644 lua/tobias/init.lua create mode 100644 lua/tobias/lazy/colors.lua create mode 100644 lua/tobias/lazy/init.lua create mode 100644 lua/tobias/lazy/lsp.lua create mode 100644 lua/tobias/lazy/telescope.lua create mode 100644 lua/tobias/lazy/treesitter.lua create mode 100644 lua/tobias/lazy_init.lua create mode 100644 lua/tobias/remap.lua create mode 100644 lua/tobias/set.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..f12c526 --- /dev/null +++ b/init.lua @@ -0,0 +1 @@ +require("tobias") diff --git a/lua/tobias/init.lua b/lua/tobias/init.lua new file mode 100644 index 0000000..10b2f72 --- /dev/null +++ b/lua/tobias/init.lua @@ -0,0 +1,3 @@ +require("tobias.remap") +require("tobias.set") +require("tobias.lazy_init") diff --git a/lua/tobias/lazy/colors.lua b/lua/tobias/lazy/colors.lua new file mode 100644 index 0000000..c345f9d --- /dev/null +++ b/lua/tobias/lazy/colors.lua @@ -0,0 +1,91 @@ +function ColorMyPencils(color) + color = color or "rose-pine-moon" + vim.cmd.colorscheme(color) + + vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) + vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) +end + +return { + + { + "erikbackman/brightburn.vim", + }, + + { + "folke/tokyonight.nvim", + lazy = false, + opts = {}, + config = function() + ColorMyPencils() + end + }, + { + "ellisonleao/gruvbox.nvim", + name = "gruvbox", + config = function() + require("gruvbox").setup({ + terminal_colors = true, -- add neovim terminal colors + undercurl = true, + underline = false, + bold = true, + italic = { + strings = false, + emphasis = false, + comments = false, + operators = false, + folds = false, + }, + strikethrough = true, + invert_selection = false, + invert_signs = false, + invert_tabline = false, + invert_intend_guides = false, + inverse = true, -- invert background for search, diffs, statuslines and errors + contrast = "", -- can be "hard", "soft" or empty string + palette_overrides = {}, + overrides = {}, + dim_inactive = false, + transparent_mode = false, + }) + end, + }, + { + "folke/tokyonight.nvim", + config = function() + require("tokyonight").setup({ + -- your configuration comes here + -- or leave it empty to use the default settings + style = "storm", -- The theme comes in three styles, `storm`, `moon`, a darker variant `night` and `day` + transparent = true, -- Enable this to disable setting the background color + terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim + styles = { + -- Style to be applied to different syntax groups + -- Value is any valid attr-list value for `:help nvim_set_hl` + comments = { italic = false }, + keywords = { italic = false }, + -- Background styles. Can be "dark", "transparent" or "normal" + sidebars = "dark", -- style for sidebars, see below + floats = "dark", -- style for floating windows + }, + }) + end + }, + + { + "rose-pine/neovim", + name = "rose-pine", + config = function() + require('rose-pine').setup({ + disable_background = true, + styles = { + italic = false, + }, + }) + + ColorMyPencils(); + end + }, + + +} diff --git a/lua/tobias/lazy/init.lua b/lua/tobias/lazy/init.lua new file mode 100644 index 0000000..aa12dbe --- /dev/null +++ b/lua/tobias/lazy/init.lua @@ -0,0 +1,8 @@ +return { + + { + "nvim-lua/plenary.nvim", + }, + + "eandrju/cellular-automaton.nvim", +} diff --git a/lua/tobias/lazy/lsp.lua b/lua/tobias/lazy/lsp.lua new file mode 100644 index 0000000..6f0eaea --- /dev/null +++ b/lua/tobias/lazy/lsp.lua @@ -0,0 +1,52 @@ +return { + "neovim/nvim-lspconfig", + dependencies = { + "stevearc/conform.nvim", + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "hrsh7th/nvim-cmp", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + "j-hui/fidget.nvim", + }, + + config = function() + require("conform").setup({ + formatters_by_ft = { + } + }) + local cmp = require('cmp') + local cmp_lsp = require("cmp_nvim_lsp") + local capabilities = vim.tbl_deep_extend( + "force", + {}, + vim.lsp.protocol.make_client_capabilities(), + cmp_lsp.default_capabilities()) + + require("fidget").setup({}) + require("mason").setup() +-- require("mason-lspconfig").setup({ +-- handlers = { +-- function(server_name) -- default handler (optional) +-- require("lspconfig")[server_name].setup { +-- capabilities = capabilities +-- } +-- end, + + vim.diagnostic.config({ + -- update_in_insert = true, + float = { + focusable = false, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + }) + end +} diff --git a/lua/tobias/lazy/telescope.lua b/lua/tobias/lazy/telescope.lua new file mode 100644 index 0000000..3b861b9 --- /dev/null +++ b/lua/tobias/lazy/telescope.lua @@ -0,0 +1,29 @@ +return { + "nvim-telescope/telescope.nvim", + + tag = "0.1.5", + + dependencies = { + "nvim-lua/plenary.nvim" + }, + + config = function() + require('telescope').setup({}) + + local builtin = require('telescope.builtin') + vim.keymap.set('n', 'pf', builtin.find_files, {}) + vim.keymap.set('n', '', builtin.git_files, {}) + vim.keymap.set('n', 'pws', function() + local word = vim.fn.expand("") + builtin.grep_string({ search = word }) + end) + vim.keymap.set('n', 'pWs', function() + local word = vim.fn.expand("") + builtin.grep_string({ search = word }) + end) + vim.keymap.set('n', 'ps', function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }) + end) + vim.keymap.set('n', 'vh', builtin.help_tags, {}) + end +} diff --git a/lua/tobias/lazy/treesitter.lua b/lua/tobias/lazy/treesitter.lua new file mode 100644 index 0000000..8d9e204 --- /dev/null +++ b/lua/tobias/lazy/treesitter.lua @@ -0,0 +1,86 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + require("nvim-treesitter.configs").setup({ + -- A list of parser names, or "all" + ensure_installed = { + "vimdoc", "lua", "bash", "yaml", -- "ansible", + }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don"t have `tree-sitter` CLI installed locally + auto_install = true, + + indent = { + enable = true + }, + + highlight = { + -- `false` will disable the whole extension + enable = true, + disable = function(lang, buf) + if lang == "html" then + print("disabled") + return true + end + + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + vim.notify( + "File larger than 100KB treesitter disabled for performance", + vim.log.levels.WARN, + {title = "Treesitter"} + ) + return true + end + end, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on "syntax" being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = { "markdown" }, + }, + }) + + local treesitter_parser_config = require("nvim-treesitter.parsers").get_parser_configs() + treesitter_parser_config.templ = { + install_info = { + url = "https://github.com/vrischmann/tree-sitter-templ.git", + files = {"src/parser.c", "src/scanner.c"}, + branch = "master", + }, + } + + vim.treesitter.language.register("templ", "templ") + end + }, + + { + "nvim-treesitter/nvim-treesitter-context", + after = "nvim-treesitter", + config = function() + require'treesitter-context'.setup{ + enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) + multiwindow = false, -- Enable multiwindow support. + max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. + min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. + line_numbers = true, + multiline_threshold = 20, -- Maximum number of lines to show for a single context + trim_scope = 'outer', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' + mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline' + -- Separator between context and content. Should be a single character string, like '-'. + -- When separator is set, the context will only show up when there are at least 2 lines above cursorline. + separator = nil, + zindex = 20, -- The Z-index of the context window + on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching + } + end + } +} diff --git a/lua/tobias/lazy_init.lua b/lua/tobias/lazy_init.lua new file mode 100644 index 0000000..97e9d78 --- /dev/null +++ b/lua/tobias/lazy_init.lua @@ -0,0 +1,17 @@ +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({ + spec = "tobias.lazy", + change_detection = { notify = false } +}) diff --git a/lua/tobias/remap.lua b/lua/tobias/remap.lua new file mode 100644 index 0000000..2ab7999 --- /dev/null +++ b/lua/tobias/remap.lua @@ -0,0 +1,25 @@ +vim.g.mapleader = " " +vim.keymap.set("n", "pv", vim.cmd.Ex) + +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +vim.keymap.set("n", "J", "mzJ`z") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") +vim.keymap.set("n", "=ap", "ma=ap'a") + +-- greatest remap ever +vim.keymap.set("x", "p", [["_dP]]) + +-- next greatest remap ever : asbjornHaland +vim.keymap.set({"n", "v"}, "y", [["+y]]) +vim.keymap.set("n", "Y", [["+Y]]) + +vim.keymap.set({"n", "v"}, "d", "\"_d") + +vim.keymap.set("i", "", "") + +vim.keymap.set("n", "Q", "") diff --git a/lua/tobias/set.lua b/lua/tobias/set.lua new file mode 100644 index 0000000..f1dfe31 --- /dev/null +++ b/lua/tobias/set.lua @@ -0,0 +1,13 @@ +vim.opt.nu = true + +vim.opt.tabstop = 2 +vim.opt.softtabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.scrolloff = 8