From 71896e05afd4d53f7496769d4de17bb0890c26d1 Mon Sep 17 00:00:00 2001 From: n Date: Sun, 11 Aug 2024 01:40:33 +0100 Subject: [PATCH] initial commit. --- .gitignore | 2 + init.lua | 1 + lua/nat/init.lua | 1 + lua/nat/lazy/cloak.lua | 26 ++++++++++ lua/nat/lazy/colors.lua | 48 ++++++++++++++++++ lua/nat/lazy/copilot-chat.lua | 15 ++++++ lua/nat/lazy/copilot.lua | 49 +++++++++++++++++++ lua/nat/lazy/init.lua | 7 +++ lua/nat/lazy/lsp.lua | 91 +++++++++++++++++++++++++++++++++++ lua/nat/lazy/telescope.lua | 30 ++++++++++++ lua/nat/lazy/treesitter.lua | 48 ++++++++++++++++++ lua/nat/lazy/undotree.lua | 9 ++++ lua/nat/lazy/zenmode.lua | 37 ++++++++++++++ lua/nat/lazy_init.lua | 37 ++++++++++++++ lua/nat/packer.lua | 83 ++++++++++++++++++++++++++++++++ lua/nat/set.lua | 34 +++++++++++++ 16 files changed, 518 insertions(+) create mode 100644 .gitignore create mode 100644 init.lua create mode 100644 lua/nat/init.lua create mode 100644 lua/nat/lazy/cloak.lua create mode 100644 lua/nat/lazy/colors.lua create mode 100644 lua/nat/lazy/copilot-chat.lua create mode 100644 lua/nat/lazy/copilot.lua create mode 100644 lua/nat/lazy/init.lua create mode 100644 lua/nat/lazy/lsp.lua create mode 100644 lua/nat/lazy/telescope.lua create mode 100644 lua/nat/lazy/treesitter.lua create mode 100644 lua/nat/lazy/undotree.lua create mode 100644 lua/nat/lazy/zenmode.lua create mode 100644 lua/nat/lazy_init.lua create mode 100644 lua/nat/packer.lua create mode 100644 lua/nat/set.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cbd542f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +init.vim.old +lazy-lock.json diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..73948fb --- /dev/null +++ b/init.lua @@ -0,0 +1 @@ +require("nat") diff --git a/lua/nat/init.lua b/lua/nat/init.lua new file mode 100644 index 0000000..d73162a --- /dev/null +++ b/lua/nat/init.lua @@ -0,0 +1 @@ +require("nat.lazy_init") diff --git a/lua/nat/lazy/cloak.lua b/lua/nat/lazy/cloak.lua new file mode 100644 index 0000000..2dd083f --- /dev/null +++ b/lua/nat/lazy/cloak.lua @@ -0,0 +1,26 @@ +return { + "laytan/cloak.nvim", + config = function() + require("cloak").setup({ + enabled = true, + cloak_character = "*", + -- The applied highlight group (colors) on the cloaking, see `:h highlight`. + highlight_group = "Comment", + patterns = { + { + -- Match any file starting with ".env". + -- This can be a table to match multiple file patterns. + file_pattern = { + ".env*", + "wrangler.toml", + ".dev.vars", + }, + -- Match an equals sign and any character after it. + -- This can also be a table of patterns to cloak, + -- example: cloak_pattern = { ":.+", "-.+" } for yaml files. + cloak_pattern = "=.+" + }, + }, + }) + end +} diff --git a/lua/nat/lazy/colors.lua b/lua/nat/lazy/colors.lua new file mode 100644 index 0000000..479ad1b --- /dev/null +++ b/lua/nat/lazy/colors.lua @@ -0,0 +1,48 @@ +function ColorMyPencils(color) + color = color or "rose-pine" + vim.cmd.colorscheme(color) + + vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) + vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) + +end + +return { + { + "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, + }) + + vim.cmd("colorscheme rose-pine") + + ColorMyPencils() + end + }, + + +} diff --git a/lua/nat/lazy/copilot-chat.lua b/lua/nat/lazy/copilot-chat.lua new file mode 100644 index 0000000..797f55b --- /dev/null +++ b/lua/nat/lazy/copilot-chat.lua @@ -0,0 +1,15 @@ +return { + { + "CopilotC-Nvim/CopilotChat.nvim", + branch = "canary", + dependencies = { + { "zbirenbaum/copilot.lua" }, -- or github/copilot.vim + { "nvim-lua/plenary.nvim" }, -- for curl, log wrapper + }, + opts = { + debug = true, -- Enable debugging + -- See Configuration section for rest + }, + -- See Commands section for default commands if you want to lazy load on them + }, +} diff --git a/lua/nat/lazy/copilot.lua b/lua/nat/lazy/copilot.lua new file mode 100644 index 0000000..eaff0d8 --- /dev/null +++ b/lua/nat/lazy/copilot.lua @@ -0,0 +1,49 @@ +return { + "zbirenbaum/copilot.lua", + config = function() + require('copilot').setup({ + panel = { + enabled = true, + auto_refresh = false, + keymap = { + jump_prev = "[[", + jump_next = "]]", + accept = "", + refresh = "gr", + open = "" + }, + layout = { + position = "bottom", -- | top | left | right + ratio = 0.4 + }, + }, + suggestion = { + enabled = true, + auto_trigger = false, + hide_during_completion = true, + debounce = 75, + keymap = { + accept = "", + accept_word = false, + accept_line = false, + next = "", + prev = "", + dismiss = "", + }, + }, + filetypes = { + yaml = false, + markdown = false, + help = false, + gitcommit = false, + gitrebase = false, + hgcommit = false, + svn = false, + cvs = false, + ["."] = false, + }, + copilot_node_command = 'node', -- Node.js version must be > 18.x + server_opts_overrides = {}, + }) + end +} diff --git a/lua/nat/lazy/init.lua b/lua/nat/lazy/init.lua new file mode 100644 index 0000000..2a6588c --- /dev/null +++ b/lua/nat/lazy/init.lua @@ -0,0 +1,7 @@ +return { + { "nvim-lua/plenary.nvim", name = "plenary" }, + "github/copilot.vim", + "eandrju/cellular-automaton.nvim", + "gpanders/editorconfig.nvim", +} + diff --git a/lua/nat/lazy/lsp.lua b/lua/nat/lazy/lsp.lua new file mode 100644 index 0000000..b257b49 --- /dev/null +++ b/lua/nat/lazy/lsp.lua @@ -0,0 +1,91 @@ +return { + "neovim/nvim-lspconfig", + dependencies = { + "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() + 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({ + ensure_installed = { + "lua_ls", + "rust_analyzer", + "tsserver", + }, + handlers = { + function(server_name) -- default handler (optional) + + require("lspconfig")[server_name].setup { + capabilities = capabilities + } + end, + + ["lua_ls"] = function() + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup { + capabilities = capabilities, + settings = { + Lua = { + diagnostics = { + globals = { "vim", "it", "describe", "before_each", "after_each" }, + } + } + } + } + end, + } + }) + + local cmp_select = { behavior = cmp.SelectBehavior.Select } + + cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.complete(), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, -- For luasnip users. + }, { + { name = 'buffer' }, + }) + }) + + vim.diagnostic.config({ + -- update_in_insert = true, + float = { + focusable = false, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + }) + end +} diff --git a/lua/nat/lazy/telescope.lua b/lua/nat/lazy/telescope.lua new file mode 100644 index 0000000..185e353 --- /dev/null +++ b/lua/nat/lazy/telescope.lua @@ -0,0 +1,30 @@ +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/nat/lazy/treesitter.lua b/lua/nat/lazy/treesitter.lua new file mode 100644 index 0000000..bc04049 --- /dev/null +++ b/lua/nat/lazy/treesitter.lua @@ -0,0 +1,48 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + require("nvim-treesitter.configs").setup({ + -- A list of parser names, or "all" + ensure_installed = { + "vimdoc", "javascript", "typescript", "vue", "lua", "yaml", + "jsdoc", "bash", "powershell", "c_sharp", "json", "sql", + "vim", "html", "css", "scss", "jsonc", "python", "http", + "xml" + }, + + -- 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, + + -- 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 +} diff --git a/lua/nat/lazy/undotree.lua b/lua/nat/lazy/undotree.lua new file mode 100644 index 0000000..f76ae05 --- /dev/null +++ b/lua/nat/lazy/undotree.lua @@ -0,0 +1,9 @@ + +return { + "mbbill/undotree", + + config = function() + vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) + end +} + diff --git a/lua/nat/lazy/zenmode.lua b/lua/nat/lazy/zenmode.lua new file mode 100644 index 0000000..3b20707 --- /dev/null +++ b/lua/nat/lazy/zenmode.lua @@ -0,0 +1,37 @@ + +return { + "folke/zen-mode.nvim", + config = function() + vim.keymap.set("n", "zz", function() + require("zen-mode").setup { + window = { + width = 90, + options = { } + }, + } + require("zen-mode").toggle() + vim.wo.wrap = false + vim.wo.number = true + vim.wo.rnu = true + ColorMyPencils() + end) + + + vim.keymap.set("n", "zZ", function() + require("zen-mode").setup { + window = { + width = 80, + options = { } + }, + } + require("zen-mode").toggle() + vim.wo.wrap = false + vim.wo.number = false + vim.wo.rnu = false + vim.opt.colorcolumn = "0" + ColorMyPencils() + end) + end +} + + diff --git a/lua/nat/lazy_init.lua b/lua/nat/lazy_init.lua new file mode 100644 index 0000000..7a42bd2 --- /dev/null +++ b/lua/nat/lazy_init.lua @@ -0,0 +1,37 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local out = vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", + 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 = "nat.lazy", + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "habamax" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/lua/nat/packer.lua b/lua/nat/packer.lua new file mode 100644 index 0000000..30321ee --- /dev/null +++ b/lua/nat/packer.lua @@ -0,0 +1,83 @@ +-- This file can be loaded by calling `lua require("plugins")` from your init.vim + +-- Only required if you have packer configured as `opt` +vim.cmd.packadd("packer.nvim") + +return require("packer").startup(function(use) + -- Packer can manage itself + use "wbthomason/packer.nvim" + + use { + "nvim-telescope/telescope.nvim", tag = "0.1.0", + -- or , branch = "0.1.x", + requires = { {"nvim-lua/plenary.nvim"} } + } + + use("folke/tokyonight.nvim") + + use({ + "rose-pine/neovim", + as = "rose-pine", + config = function() + vim.cmd("colorscheme rose-pine") + end + }) + + use({ + "folke/trouble.nvim", + config = function() + require("trouble").setup { + icons = false, + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + } + end + }) + + use { + 'nvim-treesitter/nvim-treesitter', + run = function() + local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) + ts_update() + end,} + use("nvim-treesitter/playground") + + use("~/personal/harpoon") + + use("theprimeagen/vim-be-good") + use("theprimeagen/refactoring.nvim") + use("mbbill/undotree") + use("tpope/vim-fugitive") + --use("nvim-treesitter/nvim-treesitter-context"); + + use { + "VonHeikemen/lsp-zero.nvim", + branch = "v1.x", + requires = { + -- LSP Support + {"neovim/nvim-lspconfig"}, + {"williamboman/mason.nvim"}, + {"williamboman/mason-lspconfig.nvim"}, + + -- Autocompletion + {"hrsh7th/nvim-cmp"}, + {"hrsh7th/cmp-buffer"}, + {"hrsh7th/cmp-path"}, + {"saadparwaiz1/cmp_luasnip"}, + {"hrsh7th/cmp-nvim-lsp"}, + {"hrsh7th/cmp-nvim-lua"}, + + -- Snippets + {"L3MON4D3/LuaSnip"}, + {"rafamadriz/friendly-snippets"}, + } + } + + use("folke/zen-mode.nvim") + use("github/copilot.vim") + use("eandrju/cellular-automaton.nvim") + use("laytan/cloak.nvim") + +end) + diff --git a/lua/nat/set.lua b/lua/nat/set.lua new file mode 100644 index 0000000..600428a --- /dev/null +++ b/lua/nat/set.lua @@ -0,0 +1,34 @@ +vim.g.mapleader = "" + +vim.opt.guicursor = "" + +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.tabstop = 2 +vim.opt.softtabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = false + +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.opt.termguicolors = true + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "yes" +vim.opt.isfname:append("@-@") + +vim.opt.updatetime = 50 + +vim.opt.colorcolumn = "80" +