From c591c88f435d250797cfe43175cbdf9ac9e13205 Mon Sep 17 00:00:00 2001 From: Oliver Ladner Date: Mon, 20 Nov 2023 22:42:11 +0100 Subject: [PATCH] add first working draft --- init.lua | 14 +++++++ lazy-lock.json | 12 ++++++ lua/weeheavy/init.lua | 11 +++++ lua/weeheavy/lazy.lua | 16 ++++++++ lua/weeheavy/plugins/devicons.lua | 4 ++ lua/weeheavy/plugins/nightfox.lua | 7 ++++ lua/weeheavy/plugins/sleuth.lua | 3 ++ lua/weeheavy/plugins/telescope.lua | 4 ++ lua/weeheavy/plugins/treesitter-context.lua | 5 +++ lua/weeheavy/plugins/treesitter.lua | 45 +++++++++++++++++++++ lua/weeheavy/plugins/which-key.lua | 24 +++++++++++ lua/weeheavy/prefs.lua | 24 +++++++++++ lua/weeheavy/remap.lua | 10 +++++ 13 files changed, 179 insertions(+) create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/weeheavy/init.lua create mode 100644 lua/weeheavy/lazy.lua create mode 100644 lua/weeheavy/plugins/devicons.lua create mode 100644 lua/weeheavy/plugins/nightfox.lua create mode 100644 lua/weeheavy/plugins/sleuth.lua create mode 100644 lua/weeheavy/plugins/telescope.lua create mode 100644 lua/weeheavy/plugins/treesitter-context.lua create mode 100644 lua/weeheavy/plugins/treesitter.lua create mode 100644 lua/weeheavy/plugins/which-key.lua create mode 100644 lua/weeheavy/prefs.lua create mode 100644 lua/weeheavy/remap.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..0614e71 --- /dev/null +++ b/init.lua @@ -0,0 +1,14 @@ +--[[ +My simple Neovim configuration. Made from scratch, inspired by +https://www.youtube.com/watch?v=w7i4amO_zaE + +EXTERNAL DEPENDENCIES: +- ripgrep (https://github.com/BurntSushi/ripgrep, used by telescope) +- fd (https://github.com/sharkdp/fd, used by telescope) + +CHANGELOG: + - 2023-11-20: init, lazy, fuzzy, remaps +--]] + +-- leader key must be defined before lazy.nvim) +require("weeheavy") diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..6abcb7e --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,12 @@ +{ + "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, + "nightfox.nvim": { "branch": "main", "commit": "6a6076bd678f825ffbe16ec97807793c3167f1a7" }, + "nvim-treesitter": { "branch": "master", "commit": "3da5cfb4a2505bc10d6fe3c193c69adac13423a8" }, + "nvim-treesitter-context": { "branch": "master", "commit": "ec7f160375226d90f16a019d175be730e4ac456b" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "dbcd9388e3b119a87c785e10a00d62876077d23d" }, + "nvim-web-devicons": { "branch": "master", "commit": "cdbcca210cf3655aa9b31ebf2422763ecd85ee5c" }, + "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, + "telescope.nvim": { "branch": "master", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" }, + "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, + "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } +} \ No newline at end of file diff --git a/lua/weeheavy/init.lua b/lua/weeheavy/init.lua new file mode 100644 index 0000000..8e0376e --- /dev/null +++ b/lua/weeheavy/init.lua @@ -0,0 +1,11 @@ +-- debug +--print("weeheavy module imported") + +-- init custom keybindings +require("weeheavy.remap") + +-- Install and configure Lazy package manager +require("weeheavy.lazy") + +-- Other preferences +require("weeheavy.prefs") diff --git a/lua/weeheavy/lazy.lua b/lua/weeheavy/lazy.lua new file mode 100644 index 0000000..4f1d266 --- /dev/null +++ b/lua/weeheavy/lazy.lua @@ -0,0 +1,16 @@ +-- Lazy package manager +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({ { import = "weeheavy.plugins" }, { import = "weeheavy.plugins.lsp" } }) +require("lazy").setup({ { import = "weeheavy.plugins" } }) diff --git a/lua/weeheavy/plugins/devicons.lua b/lua/weeheavy/plugins/devicons.lua new file mode 100644 index 0000000..a30eca8 --- /dev/null +++ b/lua/weeheavy/plugins/devicons.lua @@ -0,0 +1,4 @@ +return { + "nvim-tree/nvim-web-devicons", + lazy = true +} diff --git a/lua/weeheavy/plugins/nightfox.lua b/lua/weeheavy/plugins/nightfox.lua new file mode 100644 index 0000000..024f63b --- /dev/null +++ b/lua/weeheavy/plugins/nightfox.lua @@ -0,0 +1,7 @@ +return { + 'EdenEast/nightfox.nvim', + priority = 1000, + config = function() + vim.cmd.colorscheme 'duskfox' + end, +} diff --git a/lua/weeheavy/plugins/sleuth.lua b/lua/weeheavy/plugins/sleuth.lua new file mode 100644 index 0000000..f6f6f5f --- /dev/null +++ b/lua/weeheavy/plugins/sleuth.lua @@ -0,0 +1,3 @@ +return { + "tpope/vim-sleuth" +} diff --git a/lua/weeheavy/plugins/telescope.lua b/lua/weeheavy/plugins/telescope.lua new file mode 100644 index 0000000..097a21b --- /dev/null +++ b/lua/weeheavy/plugins/telescope.lua @@ -0,0 +1,4 @@ +return { + "nvim-telescope/telescope.nvim", tag = "0.1.4", + dependencies = { "nvim-lua/plenary.nvim" } + } diff --git a/lua/weeheavy/plugins/treesitter-context.lua b/lua/weeheavy/plugins/treesitter-context.lua new file mode 100644 index 0000000..64e8607 --- /dev/null +++ b/lua/weeheavy/plugins/treesitter-context.lua @@ -0,0 +1,5 @@ +-- Shows context of code line +-- Docs: https://github.com/nvim-treesitter/nvim-treesitter-context +return { + "nvim-treesitter/nvim-treesitter-context" +} diff --git a/lua/weeheavy/plugins/treesitter.lua b/lua/weeheavy/plugins/treesitter.lua new file mode 100644 index 0000000..c62eb1d --- /dev/null +++ b/lua/weeheavy/plugins/treesitter.lua @@ -0,0 +1,45 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + }, + config = function() + local treesitter = require("nvim-treesitter.configs") + + treesitter.setup({ + highlight = { enable = true, }, + indent = { enable = true }, + auto_install = false, + -- language list: https://github.com/nvim-treesitter/nvim-treesitter#supported-languages + ensure_installed = { + "lua", + "vim", + "vimdoc", + "bash", + "diff", + "gitignore", + "markdown", + "markdown_inline", + "elixir", + "eex", + "heex", + "yaml", + "html", + "css", + "dockerfile", + "query", + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = false, + node_decremental = "", + }, + }, + }) + end, +} diff --git a/lua/weeheavy/plugins/which-key.lua b/lua/weeheavy/plugins/which-key.lua new file mode 100644 index 0000000..2438af0 --- /dev/null +++ b/lua/weeheavy/plugins/which-key.lua @@ -0,0 +1,24 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 100 + end, + opts = { + layout = { + height = { min = 4, max = 25 }, -- min and max height of the columns + width = { min = 20, max = 50 }, -- min and max width of the columns + spacing = 3, -- spacing between columns + align = "left", -- align columns left, center or right + }, + window = { + border = "none", -- none, single, double, shadow + position = "bottom", -- bottom, top + margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left]. When between 0 and 1, will be treated as a percentage of the screen size. + padding = { 1, 2, 1, 2 }, -- extra window padding [top, right, bottom, left] + winblend = 1, -- value between 0-100 0 for fully opaque and 100 for fully transparent + zindex = 1000, -- positive value to position WhichKey above other floating windows. + }, + } +} diff --git a/lua/weeheavy/prefs.lua b/lua/weeheavy/prefs.lua new file mode 100644 index 0000000..4908ca9 --- /dev/null +++ b/lua/weeheavy/prefs.lua @@ -0,0 +1,24 @@ +-- Preferences + +-- Set highlight on search +vim.o.hlsearch = true + +-- Make line numbers default +--vim.wo.number = true +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.signcolumn = "number" + +-- Dynamic line numbers +--vim.wo.relativenumber = true + +-- highlight columns +vim.o.colorcolumn= '80,120' + +-- Sync clipboard between OS and Neovim. +-- Remove this option if you want your OS clipboard to remain independent. +-- See `:help 'clipboard'` +vim.o.clipboard = 'unnamedplus' + +-- Always keep this amount of lines above and below the cursor +vim.opt.scrolloff = 5 diff --git a/lua/weeheavy/remap.lua b/lua/weeheavy/remap.lua new file mode 100644 index 0000000..8239208 --- /dev/null +++ b/lua/weeheavy/remap.lua @@ -0,0 +1,10 @@ +-- keyboard shortcuts + +-- Leader key set to space, base for any key combo +vim.g.mapleader = " " + +vim.keymap.set("n", "r", vim.cmd.Ex, { noremap = true, desc = "netrw File Browser" }) -- netrw file explorer + +-- Telescope +vim.keymap.set("n", "e", ":Telescope file_browser", { noremap = true, desc = "Telescope Browser" }) +vim.keymap.set("n", "f", ":Telescope find_files", { noremap = true, desc = "Telescope File Search" })