From 7afd0cc72f666e4a00846845ca7af9e8efdd5576 Mon Sep 17 00:00:00 2001 From: voidarclabs Date: Thu, 21 Aug 2025 20:45:04 +0100 Subject: [PATCH] basic theme, mini and completion tools. config still needed --- init.lua | 28 ++++++++++++++++ lua/config/lazy.lua | 36 ++++++++++++++++++++ lua/plugins/cattpuccin.lua | 12 +++++++ lua/plugins/completion/cmp.lua | 50 ++++++++++++++++++++++++++++ lua/plugins/completion/conform.lua | 13 ++++++++ lua/plugins/completion/linter.lua | 24 +++++++++++++ lua/plugins/completion/lspconfig.lua | 41 +++++++++++++++++++++++ lua/plugins/mini.lua | 11 ++++++ 8 files changed, 215 insertions(+) create mode 100644 init.lua create mode 100644 lua/config/lazy.lua create mode 100644 lua/plugins/cattpuccin.lua create mode 100644 lua/plugins/completion/cmp.lua create mode 100644 lua/plugins/completion/conform.lua create mode 100644 lua/plugins/completion/linter.lua create mode 100644 lua/plugins/completion/lspconfig.lua create mode 100644 lua/plugins/mini.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..c76e1c6 --- /dev/null +++ b/init.lua @@ -0,0 +1,28 @@ +vim.g.mapleader = "" + +require("config.lazy") + +vim.opt.splitbelow = true +vim.opt.splitright = true + +vim.keymap.set("i", "jj", "") + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" +vim.opt.undofile = true + +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.cmd.colorscheme("catppuccin-mocha") + +vim.keymap.set("n", "", 'echo "Use h to move!!"') +vim.keymap.set("n", "", 'echo "Use l to move!!"') +vim.keymap.set("n", "", 'echo "Use k to move!!"') +vim.keymap.set("n", "", 'echo "Use j to move!!"') diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..ae23bf5 --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,36 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + { import = "plugins.completion" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "catppuccin" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/lua/plugins/cattpuccin.lua b/lua/plugins/cattpuccin.lua new file mode 100644 index 0000000..12f3c84 --- /dev/null +++ b/lua/plugins/cattpuccin.lua @@ -0,0 +1,12 @@ +return { + "catppuccin/nvim", + name = "catppuccin", + opts = { + transparent_background = true, -- disables setting the background color. + float = { + transparent = true, -- enable transparent floating windows + solid = false, -- use solid styling for floating windows, see |winborder| + }, + show_end_of_buffer = true, -- shows the '~' characters after the end of buffers + } +} diff --git a/lua/plugins/completion/cmp.lua b/lua/plugins/completion/cmp.lua new file mode 100644 index 0000000..da90a32 --- /dev/null +++ b/lua/plugins/completion/cmp.lua @@ -0,0 +1,50 @@ +return { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", -- Completion for snippets + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping.confirm({ select = true }), -- Confirm selection with Enter + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, -- This should provide LSP completions like for ESLint + -- { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }), + }) + end, +} diff --git a/lua/plugins/completion/conform.lua b/lua/plugins/completion/conform.lua new file mode 100644 index 0000000..ec7016c --- /dev/null +++ b/lua/plugins/completion/conform.lua @@ -0,0 +1,13 @@ +return { + "stevearc/conform.nvim", + config = function() + require("conform").setup({ + formatters_by_ft = { + lua = { "stylua" }, + javascript = { "prettier" }, + python = { "black" }, + }, + format_on_save = true, + }) + end, +} diff --git a/lua/plugins/completion/linter.lua b/lua/plugins/completion/linter.lua new file mode 100644 index 0000000..aa285c5 --- /dev/null +++ b/lua/plugins/completion/linter.lua @@ -0,0 +1,24 @@ +return { + "mfussenegger/nvim-lint", + config = function() + local lint = require("lint") + + -- Explicitly define linters for each file type (without ast_grep) + lint.linters_by_ft = { + python = { "flake8" }, + javascript = { "eslint" }, + typescript = { "eslint" }, + } + + -- Auto-run the linter only for the configured filetypes + vim.api.nvim_create_autocmd("BufWritePost", { + pattern = "!*.lua", + callback = function() + local ft = vim.bo.filetype + if lint.linters_by_ft[ft] then + lint.try_lint() + end + end, + }) + end, +} diff --git a/lua/plugins/completion/lspconfig.lua b/lua/plugins/completion/lspconfig.lua new file mode 100644 index 0000000..3490287 --- /dev/null +++ b/lua/plugins/completion/lspconfig.lua @@ -0,0 +1,41 @@ +return { + "neovim/nvim-lspconfig", + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + }, + config = function() + require("mason").setup() + require("mason-lspconfig").setup({ + ensure_installed = { "ts_ls", "lua_ls", "pyright", "rust_analyzer", "eslint" }, -- Add your desired LSPs + automatic_installation = true, + }) + + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup({}) + --Enable (broadcasting) snippet capability for completion + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities.textDocument.completion.completionItem.snippetSupport = true + + vim.lsp.config("cssls", { + capabilities = capabilities, + }) + lspconfig.pyright.setup({}) + lspconfig.cssls.setup({}) + lspconfig.ts_ls.setup({ + capabilities = capabilities, + }) + lspconfig.rust_analyzer.setup({}) + lspconfig.emmet_ls.setup({ + capabilities = require("cmp_nvim_lsp").default_capabilities(), + filetypes = { "html", "css", "javascriptreact", "typescriptreact" }, -- Add more if needed + init_options = { + html = { + options = { + ["bem.enabled"] = true, + }, + }, + }, + }) + end, + } diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua new file mode 100644 index 0000000..f94ecf8 --- /dev/null +++ b/lua/plugins/mini.lua @@ -0,0 +1,11 @@ +return { + "echasnovski/mini.nvim", + version = "", + config = function() + require('mini.pairs').setup() -- Bracket pairs and stuff + require("mini.ai").setup() -- Around and In extension for visual mode + require("mini.surround").setup() -- Suround selections with characters + + require("mini.icons").setup() -- Icon provider + end, +}