From 7080c2325f33601b57409adb9abc3e808c6f40de Mon Sep 17 00:00:00 2001 From: John Costa Date: Mon, 7 Oct 2024 21:48:03 +0100 Subject: [PATCH] feat(neovim): from scratch! --- dotfiles.service | 13 +++++ nvim/init.lua | 12 +++++ nvim/lazy-lock.json | 13 +++++ nvim/lazy.lua | 18 +++++++ nvim/lua/plugins/init.lua | 83 ++++++++++++++++++++++++++++++++ nvim/mappings.lua | 22 +++++++++ scripts/manager.bash | 4 +- starship.toml | 99 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 262 insertions(+), 2 deletions(-) create mode 100644 dotfiles.service create mode 100644 nvim/init.lua create mode 100644 nvim/lazy-lock.json create mode 100644 nvim/lazy.lua create mode 100644 nvim/lua/plugins/init.lua create mode 100644 nvim/mappings.lua mode change 100644 => 100755 scripts/manager.bash create mode 100644 starship.toml diff --git a/dotfiles.service b/dotfiles.service new file mode 100644 index 00000000..fcd6400b --- /dev/null +++ b/dotfiles.service @@ -0,0 +1,13 @@ +[Unit] +Description=Dotfile manager service. +After=network.target +After=systemd-user-sessions.service +After=network-online.target + +[Service] +User=john +WorkingDirectory=~ +ExecStart=Code/dotfiles/scripts/manager.bash + +[Install] +WantedBy=multi-user.target diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 00000000..b4731486 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,12 @@ +require("./mappings") +require("./lazy") + +-- Guard (Linters + Formatters) +vim.g.guard_config = { + fmt_on_save = true, + lsp_as_default_formatter = true, + save_on_fmt = true, +} + +-- Sync system clipboard and neovim register +vim.opt.clipboard = { "unnamedplus" } diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json new file mode 100644 index 00000000..8829430d --- /dev/null +++ b/nvim/lazy-lock.json @@ -0,0 +1,13 @@ +{ + "guard-collection": { "branch": "main", "commit": "06da4a065b974bbedf1a5535232c90a3526f8a43" }, + "guard.nvim": { "branch": "main", "commit": "bdbc43dadd530b0058708723db76e705a4542063" }, + "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" }, + "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, + "nvim-lspconfig": { "branch": "master", "commit": "38da5bbe1eaab2394056109e48c7e195bdb8fdfe" }, + "nvim-treesitter": { "branch": "master", "commit": "0179a89656b4ce395a4487c07ae385b8425524ae" }, + "nvim-web-devicons": { "branch": "master", "commit": "f0267921c845c42685968401bc49aa65e18d3e09" }, + "nvim-window-picker": { "branch": "main", "commit": "41cfaa428577c53552200a404ae9b3a0b5719706" }, + "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, + "telescope.nvim": { "branch": "master", "commit": "74ce793a60759e3db0d265174f137fb627430355" } +} \ No newline at end of file diff --git a/nvim/lazy.lua b/nvim/lazy.lua new file mode 100644 index 00000000..cb168723 --- /dev/null +++ b/nvim/lazy.lua @@ -0,0 +1,18 @@ +-- 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) + +require("lazy").setup("plugins") diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua new file mode 100644 index 00000000..48c2ce3a --- /dev/null +++ b/nvim/lua/plugins/init.lua @@ -0,0 +1,83 @@ +return { + { + "nvimdev/guard.nvim", + -- Builtin configuration, optional + dependencies = { + "nvimdev/guard-collection", + }, + config = function() + local ft = require("guard.filetype") + ft("lua"):fmt("lsp"):append("stylua") + ft("typescript,javascript,typescriptreact"):fmt("prettierd"):lint("eslint_d") + end, + }, + { + "nvim-telescope/telescope.nvim", + tag = "0.1.x", + dependencies = { "nvim-lua/plenary.nvim" }, + }, + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + local configs = require("nvim-treesitter.configs") + + configs.setup({ + ensure_installed = { "lua", "javascript", "typescript", "html" }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + }) + end, + }, + + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + { + "s1n7ax/nvim-window-picker", + version = "2.*", + config = function() + require("window-picker").setup({ + filter_rules = { + include_current_win = false, + autoselect_one = true, + -- filter using buffer options + bo = { + -- if the file type is one of following, the window will be ignored + filetype = { "neo-tree", "neo-tree-popup", "notify" }, + -- if the buffer type is one of following, the window will be ignored + buftype = { "terminal", "quickfix" }, + }, + }, + }) + end, + }, + }, + config = function() + require("neo-tree").setup({ + close_if_last_window = false, + }) + end, + }, + { + "neovim/nvim-lspconfig", + config = function() + require("lspconfig").lua_ls.setup({ + settings = { + Lua = { + diagnostics = { globals = { "vim", "require" } }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + }, + }, + }, + }) + end, + }, +} diff --git a/nvim/mappings.lua b/nvim/mappings.lua new file mode 100644 index 00000000..dc672fb2 --- /dev/null +++ b/nvim/mappings.lua @@ -0,0 +1,22 @@ +vim.g.mapleader = " " + +-- Save -- +vim.keymap.set("n", "", "w") + +-- Split navigation -- +vim.keymap.set("n", "", "h") +vim.keymap.set("n", "", "j") +vim.keymap.set("n", "", "k") +vim.keymap.set("n", "", "l") + +-- Buffers -- +vim.keymap.set("n", "x", "bd") + +-- Telescope Mappings -- +local builtin = require("telescope.builtin") +vim.keymap.set("n", "ff", builtin.find_files, { desc = "Telescope find files" }) +vim.keymap.set("n", "fw", builtin.live_grep, { desc = "Telescope live grep" }) + +-- Neo Tree -- +vim.keymap.set("n", "", " Neotree toggle ") +vim.keymap.set("n", "e", " Neotree focus ") diff --git a/scripts/manager.bash b/scripts/manager.bash old mode 100644 new mode 100755 index 819f1b52..e801de98 --- a/scripts/manager.bash +++ b/scripts/manager.bash @@ -1,9 +1,9 @@ #!/bin/bash +cd ~/Code/dotfiles +git pull folders=("hypr" "ags" "tmux" "lazygit" "kitty" "fish") -cd .. - for folder in ${folders[@]}; do echo Moving $folder rsync -a ./$folder/ ~/.config/$folder diff --git a/starship.toml b/starship.toml new file mode 100644 index 00000000..751f2fd2 --- /dev/null +++ b/starship.toml @@ -0,0 +1,99 @@ +# Don't print a new line at the start of the prompt +add_newline = false +# Pipes ╰─ ╭─ +# Powerline symbols                                    +# Wedges 🭧🭒 🭣🭧🭓 +# Random noise 🬖🬥🬔🬗 + +# format = """ +# $cmd_duration$username$hostname $directory $git_branch +# $character +# """ +format = """ +$cmd_duration$directory $git_branch +$character +""" + +# Replace the "❯" symbol in the prompt with "➜" +[character] # The name of the module we are configuring is "character" +success_symbol = "[• ](bold fg:green) " +error_symbol = "[• 󰅙](bold fg:red) " + +# Disable the package module, hiding it from the prompt completely +[package] +disabled = true + +[git_branch] +style = "bg: green" +symbol = "󰘬" +truncation_length = 4 +truncation_symbol = "" +format = "• [](bold fg:green)[$symbol $branch(:$remote_branch)](fg:black bg:green)[ ](bold fg:green)" + +[git_commit] +commit_hash_length = 4 +tag_symbol = " " + +[git_state] +format = '[\($state( $progress_current of $progress_total)\)]($style) ' +cherry_pick = "[🍒 PICKING](bold red)" + +[git_status] +conflicted = " 🏳 " +ahead = " 🏎💨 " +behind = " 😰 " +diverged = " 😵 " +untracked = " 🤷 ‍" +stashed = " 📦 " +modified = " 📝 " +staged = '[++\($count\)](green)' +renamed = " ✍️ " +deleted = " 🗑 " + +[hostname] +ssh_only = false +format = "[•$hostname](bg:cyan bold fg:black)[](bold fg:cyan )" +trim_at = ".companyname.com" +disabled = false + +[line_break] +disabled = false + +[memory_usage] +disabled = true +threshold = -1 +symbol = " " +style = "bold dimmed green" + +[time] +disabled = true +format = '🕙[\[ $time \]]($style) ' +time_format = "%T" + +[username] +style_user = "bold bg:cyan fg:black" +style_root = "red bold" +format = "[](bold fg:cyan)[$user]($style)" +disabled = false +show_always = true + +[directory] +home_symbol = "  " +read_only = "  " +style = "bg:green fg:black" +truncation_length = 6 +truncation_symbol = "••/" +format = '[](bold fg:green)[$path ]($style)[](bold fg:green)' + + +[directory.substitutions] +"Desktop" = "  " +"Documents" = "  " +"Downloads" = "  " +"Music" = " 󰎈 " +"Pictures" = "  " +"Videos" = "  " + +[cmd_duration] +min_time = 0 +format = '[](bold fg:yellow)[ $duration](bold bg:yellow fg:black)[](bold fg:yellow) •• '