diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f28e0ef --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +secrets.fish diff --git a/config/fish/config.fish b/config/fish/config.fish new file mode 100644 index 0000000..8be753b --- /dev/null +++ b/config/fish/config.fish @@ -0,0 +1,33 @@ + set --universal nvm_default_version v22.19.0 +set fish_add_path $HOME/.local/bin + +# Get directory of this config file +set -l config_dir (dirname (status current-filename)) +# go install github.com/mitranim/gow@latest +# Path to secrets file relative to config.fish +set -l secrets_file "$config_dir/secrets.fish" +set -gx GOPATH "$HOME/go" +set -gx JAVA_HOME "/usr/lib/jvm/java-17-openjdk/" +set -gx ANDROID_HOME $HOME"/Android/Sdk/" + +fish_add_path -a "$GOPATH/bin" + +# Source if it exists +if test -f $secrets_file + source $secrets_file +end + +function fish_greeting + # fastfetch + # echo $ADMIN_TOKEN + # set twing twong +end + +function cap + git commit -a && git pull && git push && git pull +end + +function pbcopy + read -lz input + echo -n $input | xclip -selection c +end diff --git a/config/fish/fish_plugins b/config/fish/fish_plugins new file mode 100644 index 0000000..9673b42 --- /dev/null +++ b/config/fish/fish_plugins @@ -0,0 +1,2 @@ +jorgebucaran/fisher +jorgebucaran/nvm.fish diff --git a/config/nvim/.luarc.json b/config/nvim/.luarc.json new file mode 100644 index 0000000..06b166f --- /dev/null +++ b/config/nvim/.luarc.json @@ -0,0 +1,10 @@ +{ + "settings": { + "Lua": { + "diagnostics": { + "globals": ["vim"] + } + } + } +} + diff --git a/config/nvim/init.lua b/config/nvim/init.lua new file mode 100644 index 0000000..d5b79fe --- /dev/null +++ b/config/nvim/init.lua @@ -0,0 +1,273 @@ +-- ----------------------------------------------------------------------------------------------- +-- General configuration +-- ----------------------------------------------------------------------------------------------- +-- Basic settings +vim.opt.hlsearch = true +vim.opt.number = true +vim.opt.mouse = "a" +vim.opt.showmode = false +vim.opt.spelllang = "en_gb" +vim.opt.title = true +vim.opt.titlestring = "nvim" + +-- Leader (this is here so plugins etc pick it up) +vim.g.mapleader = " " -- anywhere you see = hit , + +-- use nvim-tree instead +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +-- Use system clipboard +vim.opt.clipboard:append({ "unnamed", "unnamedplus" }) + +-- Display settings +vim.opt.termguicolors = true +vim.o.background = "dark" -- set to "dark" for dark theme + +-- Scrolling and UI settings +vim.opt.cursorline = true +vim.opt.cursorcolumn = true +vim.opt.signcolumn = 'yes' +vim.opt.wrap = false +vim.opt.sidescrolloff = 8 +vim.opt.scrolloff = 8 + +-- Persist undo (persists your undo history between sessions) +vim.opt.undodir = vim.fn.stdpath("cache") .. "/undo" +vim.opt.undofile = true + +-- Tab stuff +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.autoindent = true + +-- Search configuration +vim.opt.ignorecase = true +vim.opt.smartcase = true +vim.opt.gdefault = true + +-- open new split panes to right and below (as you probably expect) +vim.opt.splitright = true +vim.opt.splitbelow = true + +-- LSP +vim.lsp.inlay_hint.enable(true) + +-- ----------------------------------------------------------------------------------------------- +-- Plugin list +-- ----------------------------------------------------------------------------------------------- +local plugins = { + { "nvim-lua/plenary.nvim" }, -- used by several other plugins + { "catppuccin/nvim" }, + { "nvim-tree/nvim-web-devicons", lazy = true }, -- used by lualine and nvim-tree + { "nvim-lualine/lualine.nvim" }, -- Status line + { "nvim-tree/nvim-tree.lua" }, -- File browser + { "numToStr/Comment.nvim" }, + + { "nvim-lua/plenary.nvim" }, + { "ThePrimeagen/harpoon" }, + + -- Telescope command menu + { "nvim-telescope/telescope.nvim" }, + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + + -- TreeSitter + { "nvim-treesitter/nvim-treesitter", priority = 1000, build = ":TSUpdate" }, + + -- LSP + { 'mason-org/mason.nvim' }, -- installs LSP servers + { 'neovim/nvim-lspconfig' }, -- configures LSPs + { 'mason-org/mason-lspconfig.nvim' }, -- links installed to configured + { 'stevearc/conform.nvim' }, -- Formatting where the LSP doesn't + + -- AI trash + -- { 'supermaven-inc/supermaven-nvim' }, + + { + 'saghen/blink.cmp', -- Blink completion tool (LSP, snippets etc) + version = '1.*', -- see keymap here: + -- opts_extend = { "sources.default" } -- https://cmp.saghen.dev/configuration/keymap.html#default + + opts = { + keymap = { preset = "default" }, + sources = { + default = { "lsp", "path", "buffer" }, + }, + }, + }, +} + +-- ----------------------------------------------------------------------------------------------- +-- Plugin installation +-- ----------------------------------------------------------------------------------------------- +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", lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) +require("lazy").setup(plugins) + +-- ----------------------------------------------------------------------------------------------- +-- Plugin config +-- ----------------------------------------------------------------------------------------------- +vim.cmd.colorscheme("catppuccin") -- activate the theme +require("lualine").setup() -- the status line +require("nvim-tree").setup() -- the tree file browser panel +require("telescope").setup() -- command menu +require("Comment").setup() +-- require("supermaven-nvim").setup({}) + +-- ----------------------------------------------------------------------------------------------- +-- Treesitter (syntax highlighting and related stuff!) +-- ----------------------------------------------------------------------------------------------- +-- NB: Make sure to add more from this list! +-- https://github.com/nvim-treesitter/nvim-treesitter/tree/master#supported-languages +require("nvim-treesitter.configs").setup({ + ensure_installed = { "typescript", "python", "rust", "go" }, + sync_install = false, + auto_install = true, + highlight = { enable = true, }, +}) +vim.opt.foldmethod = "expr" +vim.opt.foldexpr = "nvim_treesitter#foldexpr()" +vim.opt.foldlevel = 99 + +-- ----------------------------------------------------------------------------------------------- +-- LSP +-- ----------------------------------------------------------------------------------------------- +-- NB: These will FAIL if you don't have the language toolchains installed! +-- NB: Make sure to add more from this list! +-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md +require("mason").setup() +require("mason-lspconfig").setup({ ensure_installed = { "gopls", "bashls", "beautysh" } }) + +require("conform").setup({ + default_format_opts = { lsp_format = "fallback" }, -- Many languages can be formatted directly by their LSP + formatters_by_ft = { -- but some can't, so conform is for those ones + bash = { "beautysh" }, + javascript = { "prettier" }, + javascriptreact = { "prettier" }, + typescript = { "prettier" }, + typescriptreact = { "prettier" }, + json = { "prettier" }, + html = { "prettier" }, + css = { "prettier" }, + }, +}) + +-- ----------------------------------------------------------------------------------------------- +-- Keymap settings +-- ----------------------------------------------------------------------------------------------- +-- Basic keys +vim.keymap.set("n", "", ":") -- hit to start a command, quicker than : +-- vim.keymap.set("n", "q", "") -- "u" is undo, I map "q" to redo + +-- Search navigation +-- n is always forward, N is always backward +-- ' is now forward and ; is backward +vim.keymap.set("n", "n", "v:searchforward ? 'n' : 'N'", { expr = true }) +vim.keymap.set("n", "N", "v:searchforward ? 'N' : 'n'", { expr = true }) +vim.keymap.set({ "n", "v" }, ";", "getcharsearch().forward ? ',' : ';'", { expr = true }) +vim.keymap.set({ "n", "v" }, "'", "getcharsearch().forward ? ';' : ','", { expr = true }) + +-- toggle line numbers and wrap +vim.keymap.set("n", "n", ":set nonumber! relativenumber!") +vim.keymap.set("n", "w", ":set wrap! wrap?") + +-- Moving between splits and resizing +vim.keymap.set("n", "", "") -- use Ctrl-j (and so on) to move between splits +vim.keymap.set("n", "", "") +vim.keymap.set("n", "", "") +vim.keymap.set("n", "", "") + +vim.keymap.set("n", "", ":vertical resize -2") +vim.keymap.set("n", "", ":vertical resize +2") +vim.keymap.set("n", "", ":resize -2") +vim.keymap.set("n", "", ":resize +2") + +-- nvim-tree (file browser settings) +vim.keymap.set("n", "", ":NvimTreeFocus") +vim.keymap.set("n", "", ":NvimTreeFindFile") +vim.keymap.set("n", "", ":NvimTreeClose") + +-- Formatting +vim.keymap.set("n", "fo", require('conform').format) + +vim.keymap.set('n', 'k', vim.diagnostic.goto_next, { desc = "Next diagnostic" }) +-- vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = "Prev diagnostic" }) + +local tele_builtin = require("telescope.builtin") +vim.keymap.set("n", "ff", tele_builtin.git_files, {}) -- ,ff to find git files +vim.keymap.set("n", "fa", tele_builtin.find_files, {}) -- ,fa to find any files +vim.keymap.set("n", "fg", tele_builtin.live_grep, {}) -- ,fg to ripgrep +vim.keymap.set("n", "fb", tele_builtin.buffers, {}) -- ,fb to see recent buffers +vim.keymap.set("n", "fh", tele_builtin.help_tags, {}) -- ,fh to search help + +vim.keymap.set("n", "v", require("harpoon.ui").toggle_quick_menu, {}) -- ,fh to search help +vim.keymap.set("n", "b", require("harpoon.mark").add_file, {}) -- ,fh to search help + +-- =============================================================================================== +-- Recommended extra keymaps for a modern Neovim workflow +-- =============================================================================================== + +-- ---------------------------- +-- LSP / IDE-like keymaps +-- ---------------------------- +-- These should work in all buffers with an LSP attached +vim.keymap.set("n", "K", vim.lsp.buf.hover, { desc = "Show hover documentation" }) +vim.keymap.set("i", "", vim.lsp.buf.signature_help, { desc = "Show signature help" }) +vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Go to definition" }) +vim.keymap.set("n", "gr", vim.lsp.buf.references, { desc = "List references" }) +vim.keymap.set("n", "rn", vim.lsp.buf.rename, { desc = "Rename symbol" }) +vim.keymap.set("n", "ca", vim.lsp.buf.code_action, { desc = "Code actions" }) +vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Previous diagnostic" }) +vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Next diagnostic" }) +vim.keymap.set("n", "q", vim.diagnostic.setloclist, { desc = "Send diagnostics to location list" }) +vim.keymap.set("n", "f", function() vim.lsp.buf.format({ async = true }) end, { desc = "Format buffer" }) + +-- ---------------------------- +-- Telescope / fuzzy finding +-- ---------------------------- +-- local tele_builtin = require("telescope.builtin") +-- vim.keymap.set("n", "fs", tele_builtin.lsp_document_symbols, { desc = "Document symbols" }) +-- vim.keymap.set("n", "fS", tele_builtin.lsp_workspace_symbols, { desc = "Workspace symbols" }) +-- vim.keymap.set("n", "fo", tele_builtin.oldfiles, { desc = "Recently opened files" }) + +-- ---------------------------- +-- Clipboard convenience +-- ---------------------------- +vim.keymap.set({ "n", "v" }, "y", '"+y', { desc = "Yank to system clipboard" }) +vim.keymap.set("n", "p", '"+p', { desc = "Paste from system clipboard" }) + +-- ---------------------------- +-- Window / tab navigation enhancements +-- ---------------------------- +vim.keymap.set("n", "ww", "p", { desc = "Switch to last window" }) +vim.keymap.set("n", "to", ":tabnew", { desc = "New tab" }) +vim.keymap.set("n", "tn", ":tabnext", { desc = "Next tab" }) +vim.keymap.set("n", "tp", ":tabprevious", { desc = "Previous tab" }) + +-- ---------------------------- +-- Folding (Treesitter) +-- ---------------------------- +vim.keymap.set("n", "za", "za", { desc = "Toggle fold under cursor" }) +vim.keymap.set("n", "zR", "zR", { desc = "Open all folds" }) +vim.keymap.set("n", "zM", "zM", { desc = "Close all folds" }) + +-- ---------------------------- +-- Highlight on yank +-- ---------------------------- +vim.cmd([[ + augroup YankHighlight + autocmd! + autocmd TextYankPost * silent! lua vim.highlight.on_yank{higroup="IncSearch", timeout=200} + augroup END +]]) + +-- Show diagnostic message in a floating window +vim.keymap.set("n", "e", vim.diagnostic.open_float, { desc = "Show diagnostics in float" }) diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..561af5d --- /dev/null +++ b/deploy.sh @@ -0,0 +1,47 @@ +#!/bin/bash +source_dir="./config" +target_config_dir="$HOME/.config" + +nodejs_version="v22.21.0" + +# Ensure fish/fisher setup + install plugins +if fish -c "which fisher" >/dev/null 2>&1; then + echo "fisher is installed" +else + echo "fisher not found. installing." + # curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher + fish -c "curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher" +fi + +for dir in "$source_dir"/*/; do + if [ -d "$dir" ]; then # Check if it's a directory + dir_name=$(basename "$dir") + source=$source_dir"/"$dir_name + target=$target_config_dir"/"$dir_name + + echo "Source: " $source + echo "Target: " $target + # rm -rf $target + + if [ "$(ls -A $source)" ]; then + mkdir -p $target + cp -rf "$source/"* "$target/" + else + echo "$source is empty" + fi + fi +done + +fish -c "fisher update" + + +fish -c "set --universal nvm_default_version $nodejs_version" +if fish -c "which node" >/dev/null 2>&1; then + version=$(node --version) + echo "node is installed: $version" +else + echo "nodejs not found. installing." + fish -c "nvm install $nodejs_version" + fish -c "nvm use $nodejs_version" +fi +