From d234aca8e424c3b32e8e6f19a117ae5f440896f1 Mon Sep 17 00:00:00 2001 From: Foohoo Date: Thu, 28 Aug 2025 17:00:42 +0100 Subject: [PATCH] add nvim config --- nvim/.config/nvim/init.lua | 3 ++ nvim/.config/nvim/lazy-lock.json | 16 +++++++ nvim/.config/nvim/lua/config/lazy.lua | 35 ++++++++++++++ nvim/.config/nvim/lua/config/options.lua | 5 ++ nvim/.config/nvim/lua/plugins/.luarc.json | 5 ++ nvim/.config/nvim/lua/plugins/colorscheme.lua | 10 ++++ nvim/.config/nvim/lua/plugins/lsp-config.lua | 32 +++++++++++++ nvim/.config/nvim/lua/plugins/lualine.lua | 12 +++++ nvim/.config/nvim/lua/plugins/neotree.lua | 48 +++++++++++++++++++ nvim/.config/nvim/lua/plugins/snacks.lua | 14 ++++++ nvim/.config/nvim/lua/plugins/telescope.lua | 34 +++++++++++++ nvim/.config/nvim/lua/plugins/treesitter.lua | 16 +++++++ 12 files changed, 230 insertions(+) create mode 100644 nvim/.config/nvim/init.lua create mode 100644 nvim/.config/nvim/lazy-lock.json create mode 100644 nvim/.config/nvim/lua/config/lazy.lua create mode 100644 nvim/.config/nvim/lua/config/options.lua create mode 100644 nvim/.config/nvim/lua/plugins/.luarc.json create mode 100644 nvim/.config/nvim/lua/plugins/colorscheme.lua create mode 100644 nvim/.config/nvim/lua/plugins/lsp-config.lua create mode 100644 nvim/.config/nvim/lua/plugins/lualine.lua create mode 100644 nvim/.config/nvim/lua/plugins/neotree.lua create mode 100644 nvim/.config/nvim/lua/plugins/snacks.lua create mode 100644 nvim/.config/nvim/lua/plugins/telescope.lua create mode 100644 nvim/.config/nvim/lua/plugins/treesitter.lua diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..70c6275 --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1,3 @@ +require("config.options") +require("config.lazy") + diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..4e028a1 --- /dev/null +++ b/nvim/.config/nvim/lazy-lock.json @@ -0,0 +1,16 @@ +{ + "catppuccin": { "branch": "main", "commit": "30fa4d122d9b22ad8b2e0ab1b533c8c26c4dde86" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "1a31f824b9cd5bc6f342fc29e9a53b60d74af245" }, + "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "cea666ef965884414b1b71f6b39a537f9238bdb2" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-lspconfig": { "branch": "master", "commit": "cb33dea610b7eff240985be9f6fe219920e630ef" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-web-devicons": { "branch": "master", "commit": "4ae47f4fb18e85b80e84b729974fe65483b06aaf" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" } +} diff --git a/nvim/.config/nvim/lua/config/lazy.lua b/nvim/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..f5ee74c --- /dev/null +++ b/nvim/.config/nvim/lua/config/lazy.lua @@ -0,0 +1,35 @@ +-- 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" }, + }, + -- 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/nvim/.config/nvim/lua/config/options.lua b/nvim/.config/nvim/lua/config/options.lua new file mode 100644 index 0000000..a2cecd4 --- /dev/null +++ b/nvim/.config/nvim/lua/config/options.lua @@ -0,0 +1,5 @@ +vim.cmd("set expandtab") +vim.cmd("set tabstop=2") +vim.cmd("set softtabstop=2") +vim.cmd("set shiftwidth=2") +vim.cmd("set number") diff --git a/nvim/.config/nvim/lua/plugins/.luarc.json b/nvim/.config/nvim/lua/plugins/.luarc.json new file mode 100644 index 0000000..1e1765c --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/.luarc.json @@ -0,0 +1,5 @@ +{ + "diagnostics.globals": [ + "vim" + ] +} \ No newline at end of file diff --git a/nvim/.config/nvim/lua/plugins/colorscheme.lua b/nvim/.config/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..eb1bc29 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,10 @@ +return { + { + "catppuccin/nvim", + name = "catppuccin", + priority = 1000, + config = function() + vim.cmd.colorscheme("catppuccin-mocha") + end, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/lsp-config.lua b/nvim/.config/nvim/lua/plugins/lsp-config.lua new file mode 100644 index 0000000..9ee4b41 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/lsp-config.lua @@ -0,0 +1,32 @@ +return { + { + "mason-org/mason.nvim", + version = "^1.0.0", + config = function() + require('mason').setup() + end + }, + { + "mason-org/mason-lspconfig.nvim", + version = "^1.0.0", + opts = {}, + config = function() + require('mason-lspconfig').setup({ + ensure_installed = { "lua_ls", "ts_ls" } + }) + end + }, + { + "neovim/nvim-lspconfig", + version = "^1.0.0", + config = function() + local lspconfig = require('lspconfig') + lspconfig.lua_ls.setup({}) + lspconfig.ts_ls.setup({}) + + vim.keymap.set('n', 'K', vim.lsp.buf.hover, {}) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {}) + vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, {}) + end + } +} diff --git a/nvim/.config/nvim/lua/plugins/lualine.lua b/nvim/.config/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..d007f69 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/lualine.lua @@ -0,0 +1,12 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + lazy = false, + config = function() + require('lualine').setup({ + options = { + theme = 'dracula' + } + }) + end +} diff --git a/nvim/.config/nvim/lua/plugins/neotree.lua b/nvim/.config/nvim/lua/plugins/neotree.lua new file mode 100644 index 0000000..51f0b18 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/neotree.lua @@ -0,0 +1,48 @@ +return { + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + "nvim-tree/nvim-web-devicons", -- optional, but recommended + }, + lazy = false, -- neo-tree will lazily load itself + opts = { + filesystem = { + filtered_items = { + visible = true, + hide_dotfiles = false + } + } + }, + config = function(_, opts) + require('neo-tree').setup(opts) + vim.keymap.set('n', '', 'Neotree toggle', {}) + -- Option 2: More targeted - only when opening actual files + vim.api.nvim_create_autocmd({"BufReadPost", "BufNewFile"}, { + callback = function() + -- Check if it's a real file (has a name and isn't a special buffer) + local bufname = vim.api.nvim_buf_get_name(0) + if bufname == "" or vim.bo.buftype ~= "" then + return + end + + -- Skip if neo-tree is already visible + local manager = require("neo-tree.sources.manager") + local state = manager.get_state("filesystem") + if state.tree and state.tree.visible then + return + end + + require("neo-tree.command").execute({ action = "show", source = "filesystem" }) + end, + }) + end, + } +} + + + + + diff --git a/nvim/.config/nvim/lua/plugins/snacks.lua b/nvim/.config/nvim/lua/plugins/snacks.lua new file mode 100644 index 0000000..56b0de1 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/snacks.lua @@ -0,0 +1,14 @@ +return { + "folke/snacks.nvim", + opts = { + dashboard = { + sections = { + { section = "header" }, + { icon = " ", title = "Keymaps", section = "keys", indent = 2, padding = 1 }, + { icon = " ", title = "Recent Files", section = "recent_files", indent = 2, padding = 1 }, + { icon = " ", title = "Projects", section = "projects", indent = 2, padding = 1 }, + { section = "startup" }, + } + } + } +} diff --git a/nvim/.config/nvim/lua/plugins/telescope.lua b/nvim/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..d664f38 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,34 @@ +return { + { + 'nvim-telescope/telescope.nvim', tag = '0.1.8', + dependencies = { 'nvim-lua/plenary.nvim' }, + opts = { + defaults = { + layout_strategy = 'flex', + layout_config = { width = 0.95 }, + path_display = { 'smart' }, + }, + }, + config = function() + local builtin = require('telescope.builtin') + vim.keymap.set('n', '', builtin.find_files, { desc = 'Telescope find files' }) + vim.keymap.set('n', 'fg', builtin.live_grep, { desc = 'Telescope live grep' }) + vim.keymap.set('n', 'fb', builtin.buffers, { desc = 'Telescope buffers' }) + vim.keymap.set('n', 'fh', builtin.help_tags, { desc = 'Telescope help tags' }) + end, + }, + { + "nvim-telescope/telescope-ui-select.nvim", + config = function() + require("telescope").setup({ + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown { + } + } + } + }) + require("telescope").load_extension("ui-select") + end + } +} diff --git a/nvim/.config/nvim/lua/plugins/treesitter.lua b/nvim/.config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..f8b76bf --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,16 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + branch = 'master', + lazy = false, + build = ":TSUpdate", + config = function() + local configs = require("nvim-treesitter.configs") + configs.setup({ + ensure_installed = {"c", "lua", "vim", "vimdoc", "query", "markdown", "markdown_inline", "javascript", "typescript", "python", "html", "css"}, + highlight = { enabled = true }, + indent = { enabled = true }, + }) + end, + } +}