diff --git a/README.md b/README.md index 2e6d2bb..0fbbc83 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,18 @@ # dotfiles Dotfiles for various unix tools. + +## Alacritty +A terminal that can handle a nerd font. Used alongside lazyvim. + +## LazyVim +An upgraded and more powerful Neovim successor, a sequel to runyanjake/nvim. + +## Neovim +My nvim configuration for neovim on ubuntu. Sort of superceded by my LazyVim config. + +## Oh My Zsh! +A fancier terminal experience. + +## Tmux +A tmux configuration for making life in the editor a bit better. + diff --git a/alacritty/README.md b/alacritty/README.md index e1207c0..e194c8c 100644 --- a/alacritty/README.md +++ b/alacritty/README.md @@ -1,5 +1,5 @@ # Alacritty -A terminal that can handle a nerd font. +A terminal that can handle a nerd font. Used alongside lazyvim. ## MacOS 1. Download a release from `https://github.com/alacritty/alacritty/releases` or get it using Homebrew diff --git a/neovim/README.md b/neovim/README.md new file mode 100644 index 0000000..fc4649d --- /dev/null +++ b/neovim/README.md @@ -0,0 +1,45 @@ +# nvim +My nvim configuration for neovim on ubuntu. Sort of superceded by nvim config. + +## Folder Structure +``` +~/.config/nvim +|-- init.lua +|-- lua/ +| |-- config/ +| | |-- aaa.lua +| | |-- bbb.lua +| | |-- ccc.lua +| | |-- ddd.lua +| |-- plugins/ +| |-- xxx.lua +| |-- yyy.lua +| : +``` + +## Instructions + +### First Time Setup +1. Install the latest version of Neovim from the Neovim Launchpad PPA. Ubuntu apt has an older version, and since then much has changed, so we'll prefer the latest stable from the PPA. +- `sudo add-apt-repository ppa:neovim-ppa/stable` +- `sudo apt update` +- `sudo apt install neovim` +2. Ensure that the nvim runtimepath is correctly configured to include `~/.config.nvim`. +You can check that by executing this nvim command: `:echo &runtimepath`. +3. Both `init.lua` as well as the `lua/` folder and its contents should be symlinked to `~/.config/nvim` (Might need to create the nvim folder if first time). +- `ln -sfn /path/to/dotfiles/nvim/init.lua ~/.config/nvim/init.lua` +- `ln -sfn /path/to/dotfiles/nvim/lua ~/.config/nvim/lua` +The next time vim is opened, the config changes will apply. + +### Configuration +Configuration files live in lua/config. +The template I am using splits things up logically into a few lua files, that are all included in the top-level init.lua. + +### Plugins +Plugins live in lua/plugins. +Plugins can either be manually included in init.lua or managed by lazy nvim. +Each plugin gets its own lua file in there, and lazy or manual edits to init.lua can be used to configure what's enabled. + +## References +https://m4xshen.dev/posts/build-your-modern-neovim-config-in-lua (Using their folder structure.) + diff --git a/neovim/init.lua b/neovim/init.lua new file mode 100644 index 0000000..51fae46 --- /dev/null +++ b/neovim/init.lua @@ -0,0 +1,11 @@ +-- config files +require("config.options") +require("config.mappings") +require("config.autocmds") + +-- lazy nvim plugin manager +-- require("config.lazy") + +-- manual inclusion of plugins +require("plugins.helloWorld") + diff --git a/neovim/lua/config/autocmds.lua b/neovim/lua/config/autocmds.lua new file mode 100644 index 0000000..5948d98 --- /dev/null +++ b/neovim/lua/config/autocmds.lua @@ -0,0 +1,20 @@ +-- set tab to 4 space when entering a buffer with .java file +vim.api.nvim_create_autocmd("BufEnter", { + pattern = { "*.java" }, + callback = function() + vim.opt.shiftwidth = 4 + vim.opt.tabstop = 4 + vim.opt.softtabstop = 4 + end +}) + +-- set tab to 2 space when entering a buffer with .yml file +vim.api.nvim_create_autocmd("BufEnter", { + pattern = { "*.yml" }, + callback = function() + vim.opt.shiftwidth = 2 + vim.opt.tabstop = 2 + vim.opt.softtabstop = 2 + end +}) + diff --git a/neovim/lua/config/lazy.lua b/neovim/lua/config/lazy.lua new file mode 100644 index 0000000..7ffc959 --- /dev/null +++ b/neovim/lua/config/lazy.lua @@ -0,0 +1,17 @@ +-- install lazy.nvim +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) + +-- load plugins +require("lazy").setup("plugins") + diff --git a/neovim/lua/config/mappings.lua b/neovim/lua/config/mappings.lua new file mode 100644 index 0000000..7a02478 --- /dev/null +++ b/neovim/lua/config/mappings.lua @@ -0,0 +1,6 @@ +-- set key for nvim (effectively layer key for shortcuts in nvim) +vim.g.mapleader = "," + +-- map leader+y to copy to system clipboard in normal mode +vim.keymap.set({ "n", "v" }, "y", '"+y', { noremap = true, silent = true }) + diff --git a/neovim/lua/config/options.lua b/neovim/lua/config/options.lua new file mode 100644 index 0000000..824f1dc --- /dev/null +++ b/neovim/lua/config/options.lua @@ -0,0 +1,8 @@ +-- enable line number and relative line number +vim.opt.number = true + +-- width of a tab +vim.opt.shiftwidth = 2 +vim.opt.tabstop = 2 +vim.opt.softtabstop = 2 + diff --git a/neovim/lua/plugins/helloWorld.lua b/neovim/lua/plugins/helloWorld.lua new file mode 100644 index 0000000..2ca4c43 --- /dev/null +++ b/neovim/lua/plugins/helloWorld.lua @@ -0,0 +1,10 @@ +-- hello.lua + +-- Define a function that prints a greeting +local function hello_world() + print("Hello, Neovim!") +end + +-- Create a command ":SayHello" that runs the say_hello function +vim.api.nvim_create_user_command('HelloWorld', hello_world, {}) + diff --git a/nvim b/nvim deleted file mode 160000 index 341a1e1..0000000 --- a/nvim +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 341a1e165238a1625cd575d108a247091868ddf4