diff --git a/dotfiles/README.md b/dotfiles/README.md new file mode 100644 index 0000000..dc8836b --- /dev/null +++ b/dotfiles/README.md @@ -0,0 +1,35 @@ +# dotfiles + +My personalized set of configurations. + +## nvim (Neovim) + +Here are the plugins I'm currently using: + +- [lazy](https://github.com/folke/lazy.nvim) - Neovim plugin manager. +- [autopairs](https://github.com/windwp/nvim-autopairs) - "Autopairs" parentheses/brackets/braces/etc. +- [cmp](https://github.com/hrsh7th/nvim-cmp) - Autocompletion. +- [colorizer](https://github.com/norcalli/nvim-colorizer.lua) - Syntax highlighting. +- [conform](https://github.com/stevearc/conform.nvim) - Autoformatting. +- [gitsigns](https://github.com/lewis6991/gitsigns.nvim) - Git integration within buffer. +- [lspconfig](https://github.com/neovim/nvim-lspconfig) - Quick setup for LSP. +- [lualine](https://github.com/nvim-lualine/lualine.nvim) - Helpful status line. +- [mason](https://github.com/williamboman/mason.nvim) - Plugin manager specific to external tools (LSP/linters/formatters/etc.) +- [neo-tree](https://github.com/nvim-neo-tree/neo-tree.nvim) - File manager. +- [telescope](https://github.com/nvim-telescope/telescope.nvim) - Fuzzy finder. +- [toggleterm](https://github.com/akinsho/toggleterm.nvim) - Terminal switcher. +- [tree-sitter](https://github.com/nvim-treesitter/nvim-treesitter) - Syntax parsing for opened files. + +### Requirements + +- [luarocks](https://github.com/luarocks/luarocks) +- npm + +### Setup + +A couple of the plugins need some Node.JS packages installed first. + +``` +$ sudo npm install -g tree-sitter tree-sitter-cli typescript typescript-language-server +``` + diff --git a/dotfiles/nvim/.gitignore b/dotfiles/nvim/.gitignore new file mode 100644 index 0000000..e033bc6 --- /dev/null +++ b/dotfiles/nvim/.gitignore @@ -0,0 +1 @@ +lazy-lock.json diff --git a/dotfiles/nvim/init.lua b/dotfiles/nvim/init.lua new file mode 100644 index 0000000..3729bf9 --- /dev/null +++ b/dotfiles/nvim/init.lua @@ -0,0 +1,2 @@ +require("jodhus.settings") +require("jodhus.lazy") diff --git a/dotfiles/nvim/lua/jodhus/lazy.lua b/dotfiles/nvim/lua/jodhus/lazy.lua new file mode 100644 index 0000000..29ed7d6 --- /dev/null +++ b/dotfiles/nvim/lua/jodhus/lazy.lua @@ -0,0 +1,15 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or 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("jodhus.plugins") + diff --git a/dotfiles/nvim/lua/jodhus/plugins/autopairs.lua b/dotfiles/nvim/lua/jodhus/plugins/autopairs.lua new file mode 100644 index 0000000..fbdf5ef --- /dev/null +++ b/dotfiles/nvim/lua/jodhus/plugins/autopairs.lua @@ -0,0 +1,9 @@ +return { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = function() + require("nvim-autopairs").setup({ + disable_filetype = { "TelescopePrompt", "vim" }, + }) + end, +} diff --git a/dotfiles/nvim/lua/jodhus/plugins/cmp.lua b/dotfiles/nvim/lua/jodhus/plugins/cmp.lua new file mode 100644 index 0000000..724d5bc --- /dev/null +++ b/dotfiles/nvim/lua/jodhus/plugins/cmp.lua @@ -0,0 +1,64 @@ +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + { + "L3MON4D3/LuaSnip", + version = "v2.*", + build = "make install_jsregexp", + }, + "rafamadriz/friendly-snippets", + "onsails/lspkind.nvim", + }, + config = function() + local cmp = require("cmp") + local lspkind = require("lspkind") + local luasnip = require("luasnip") + + require("luasnip.loaders.from_vscode").lazy_load() + + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }), + formatting = { + expandable_indicator = true, + fields = { "abbr", "kind", "menu" }, + format = lspkind.cmp_format({ + mode = "symbol_text", + maxwidth = 64, + ellipsis_char = "...", + show_labelDetails = true, + before = function(entry, vim_item) + return vim_item + end, + }), + }, + }) + + vim.cmd([[ + set completeopt=menuone,noinsert,noselect + highlight! default link CmpItemKind CmpItemMenuDefault + ]]) + end, +} diff --git a/dotfiles/nvim/lua/jodhus/plugins/colorizer.lua b/dotfiles/nvim/lua/jodhus/plugins/colorizer.lua new file mode 100644 index 0000000..70baccf --- /dev/null +++ b/dotfiles/nvim/lua/jodhus/plugins/colorizer.lua @@ -0,0 +1,6 @@ +return { + "norcalli/nvim-colorizer.lua", + config = function() + require("colorizer").setup({ "*" }) + end, +} diff --git a/dotfiles/nvim/lua/jodhus/plugins/colorscheme.lua b/dotfiles/nvim/lua/jodhus/plugins/colorscheme.lua new file mode 100644 index 0000000..c813c26 --- /dev/null +++ b/dotfiles/nvim/lua/jodhus/plugins/colorscheme.lua @@ -0,0 +1,32 @@ +return { + "ellisonleao/gruvbox.nvim", + priority = 1000, + config = function() + require("gruvbox").setup({ + terminal_colors = true, + undercurl = true, + underline = true, + bold = true, + italic = { + strings = true, + emphasis = true, + comments = true, + operators = false, + folds = true, + }, + strikethrough = true, + invert_selection = false, + invert_signs = false, + invert_tabline = false, + invert_intend_guides = false, + inverse = true, + contrast = "", + palette_overrides = {}, + overrides = {}, + dim_inactive = false, + transparent_mode = false, + }) + vim.cmd("colorscheme gruvbox") + end, + opts = ..., +} diff --git a/dotfiles/nvim/lua/jodhus/plugins/formatter.lua b/dotfiles/nvim/lua/jodhus/plugins/formatter.lua new file mode 100644 index 0000000..3b4707a --- /dev/null +++ b/dotfiles/nvim/lua/jodhus/plugins/formatter.lua @@ -0,0 +1,37 @@ +return { + "stevearc/conform.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = function() + local conform = require("conform") + + conform.setup({ + formatters_by_ft = { + javascript = { "prettier" }, + typescript = { "prettier" }, + javascriptreact = { "prettier" }, + typescriptreact = { "prettier" }, + css = { "prettier" }, + html = { "prettier" }, + json = { "prettier" }, + yaml = { "prettier" }, + markdown = { "prettier" }, + lua = { "stylua" }, + python = { "isort", "black" }, + rust = { "rustfmt" }, + }, + format_on_save = { + lsp_fallback = true, + async = false, + timeout_ms = 1000, + }, + }) + + vim.keymap.set({ "n", "v" }, "f", function() + conform.format({ + lsp_fallback = true, + async = false, + timeout_ms = 1000, + }) + end, { desc = "Format file or range (in visual mode)" }) + end, +} diff --git a/dotfiles/nvim/lua/jodhus/plugins/gitsigns.lua b/dotfiles/nvim/lua/jodhus/plugins/gitsigns.lua new file mode 100644 index 0000000..aa38d0c --- /dev/null +++ b/dotfiles/nvim/lua/jodhus/plugins/gitsigns.lua @@ -0,0 +1,45 @@ +return { + "lewis6991/gitsigns.nvim", + config = function() + local gitsigns = require("gitsigns") + gitsigns.setup({ + signs = { + add = { text = "│" }, + change = { text = "│" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + untracked = { text = "┆" }, + }, + signcolumn = true, + numhl = false, + linehl = false, + word_diff = false, + watch_gitdir = { + interval = 1000, + follow_files = true, + }, + attach_to_untracked = true, + current_line_blame = false, + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", + delay = 1000, + ignore_whitespace = false, + }, + current_line_blame_formatter = ", - ", + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, + max_file_length = 40000, + preview_config = { + border = "single", + sytle = "minimal", + relative = "cursor", + row = 0, + col = 1, + }, + -- yadm = { enable = false }, + }) + end, +} diff --git a/dotfiles/nvim/lua/jodhus/plugins/lspconfig.lua b/dotfiles/nvim/lua/jodhus/plugins/lspconfig.lua new file mode 100644 index 0000000..56d903a --- /dev/null +++ b/dotfiles/nvim/lua/jodhus/plugins/lspconfig.lua @@ -0,0 +1,85 @@ +return { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "hrsh7th/cmp-nvim-lsp", + { "folke/neodev.nvim", opts = {} }, + }, + config = function() + local nvim_lsp = require("lspconfig") + local mason_lspconfig = require("mason-lspconfig") + + local protocol = require("vim.lsp.protocol") + + local on_attach = function(client, bufnr) + -- format on save + if client.server_capabilities.documentFormattingProvider then + vim.api.nvim_create_autocmd("BufWritePre", { + group = vim.api.nvim_create_augroup("Format", { clear = true }), + buffer = bufnr, + callback = function() + vim.lsp.buf.format() + end, + }) + end + end + + local capabilities = require("cmp_nvim_lsp").default_capabilities() + + mason_lspconfig.setup_handlers({ + function(server) + nvim_lsp[server].setup({ + capabilities = capabilities, + }) + end, + ["basedpyright"] = function() + nvim_lsp["basedpyright"].setup({ + on_attach = on_attach, + capabilities = capabilities, + }) + end, + ["cssls"] = function() + nvim_lsp["cssls"].setup({ + on_attach = on_attach, + capabilities = capabilities, + }) + end, + ["eslint"] = function() + nvim_lsp["eslint"].setup({ + on_attach = on_attach, + capabilities = capabilities, + }) + end, + ["html"] = function() + nvim_lsp["html"].setup({ + on_attach = on_attach, + capabilities = capabilities, + }) + end, + ["jsonls"] = function() + nvim_lsp["jsonls"].setup({ + on_attach = on_attach, + capabilities = capabilities, + }) + end, + ["rust_analyzer"] = function() + nvim_lsp["rust_analyzer"].setup({ + on_attach = on_attach, + capabilities = capabilities, + }) + end, + ["ts_ls"] = function() + nvim_lsp["ts_ls"].setup({ + on_attach = on_attach, + capabilities = capabilities, + }) + end, + ["tailwindcss"] = function() + nvim_lsp["tailwindcss"].setup({ + on_attach = on_attach, + capabilities = capabilities, + }) + end, + }) + end, +} diff --git a/dotfiles/nvim/lua/jodhus/plugins/lualine.lua b/dotfiles/nvim/lua/jodhus/plugins/lualine.lua new file mode 100644 index 0000000..473c340 --- /dev/null +++ b/dotfiles/nvim/lua/jodhus/plugins/lualine.lua @@ -0,0 +1,7 @@ +return { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("lualine").setup() + end, +} diff --git a/dotfiles/nvim/lua/jodhus/plugins/mason.lua b/dotfiles/nvim/lua/jodhus/plugins/mason.lua new file mode 100644 index 0000000..81450be --- /dev/null +++ b/dotfiles/nvim/lua/jodhus/plugins/mason.lua @@ -0,0 +1,36 @@ +return { + "williamboman/mason.nvim", + dependencies = { + "williamboman/mason-lspconfig.nvim", + "WhoIsSethDaniel/mason-tool-installer.nvim", + }, + config = function() + require("mason").setup() + + require("mason-lspconfig").setup({ + automatic_installation = true, + ensure_installed = { + "basedpyright", + "cssls", + "eslint", + "html", + "jsonls", + "rust_analyzer", + "ts_ls", + "tailwindcss", + }, + }) + + require("mason-tool-installer").setup({ + ensure_installed = { + "prettier", + "stylua", + "isort", + "black", + "pylint", + "eslint_d", + "rustfmt", + } + }) + end, +} diff --git a/dotfiles/nvim/lua/jodhus/plugins/neotree.lua b/dotfiles/nvim/lua/jodhus/plugins/neotree.lua new file mode 100644 index 0000000..ef1831c --- /dev/null +++ b/dotfiles/nvim/lua/jodhus/plugins/neotree.lua @@ -0,0 +1,16 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + config = function() + require("neo-tree").setup({ + filesystem = { + use_libuv_file_watcher = true, + }, + }) + end, +} diff --git a/dotfiles/nvim/lua/jodhus/plugins/telescope.lua b/dotfiles/nvim/lua/jodhus/plugins/telescope.lua new file mode 100644 index 0000000..5eadbee --- /dev/null +++ b/dotfiles/nvim/lua/jodhus/plugins/telescope.lua @@ -0,0 +1,15 @@ +return { + "nvim-telescope/telescope.nvim", + branch = "0.1.x", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + require("telescope").setup() + + local keymap = vim.keymap + keymap.set("n", "ff", "Telescope find_files", { desc = "Fuzzy find files in cwd." }) + keymap.set("n", "fg", "Telescope live_grep", { desc = "Fuzzy find recent files." }) + keymap.set("n", "fb", "Telescope buffers", { desc = "Find string in cwd." }) + keymap.set("n", "fs", "Telescope git_status", { desc = "Find string under cursor in cwd." }) + keymap.set("n", "fc", "Telescope git_commits", { desc = "Find todos." }) + end, +} diff --git a/dotfiles/nvim/lua/jodhus/plugins/toggleterm.lua b/dotfiles/nvim/lua/jodhus/plugins/toggleterm.lua new file mode 100644 index 0000000..5b84a9e --- /dev/null +++ b/dotfiles/nvim/lua/jodhus/plugins/toggleterm.lua @@ -0,0 +1,19 @@ +return { + "akinsho/toggleterm.nvim", + version = "*", + config = function() + require("toggleterm").setup({ + size = 10, + open_mapping = [[]], + shading_factor = 2, + direction = "float", + float_opts={ + border = "curved", + highlights = { + border = "Normal", + beackground = "Normal", + }, + }, + }) + end, +} diff --git a/dotfiles/nvim/lua/jodhus/plugins/treesitter.lua b/dotfiles/nvim/lua/jodhus/plugins/treesitter.lua new file mode 100644 index 0000000..5e9839a --- /dev/null +++ b/dotfiles/nvim/lua/jodhus/plugins/treesitter.lua @@ -0,0 +1,97 @@ +return { + "nvim-treesitter/nvim-treesitter", + event = { "BufReadPre", "BufNewFile" }, + build = ":TSUpdate", + dependencies = { + "windwp/nvim-ts-autotag", + }, + config = function() + local treesitter = require("nvim-treesitter.configs") + + treesitter.setup({ + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + indent = { enable = true }, + autotag = { enable = true }, + modules = {}, + auto_install = false, + ignore_install = {}, + sync_install = false, + ensure_installed = { + "asm", + "bash", + "c", + "c_sharp", + "cmake", + "cpp", + "css", + "csv", + "diff", + "dockerfile", + "elixir", + "git_config", + "gitattributes", + "gitcommit", + "gitignore", + "go", + "gomod", + "graphql", + "html", + "http", + "ini", + "java", + "javascript", + "json", + "json5", + "latex", + "liquidsoap", + "lua", + "m68k", + "make", + "markdown", + "markdown_inline", + "meson", + "nasm", + "nginx", + "php", + "python", + "regex", + "ruby", + "rust", + "scss", + "sql", + "ssh_config", + "tmux", + "toml", + "tsx", + "typescript", + "vim", + "vue", + "xml", + "yaml", + "zig", + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = false, + node_decremental = "", + }, + }, + rainbow = { + enable = true, + disable = { "html" }, + extended_mode = false, + max_file_lines = nil, + }, + context_commentstring = { + enable = true, + enable_autocmd = false, + }, + }) + end, +} diff --git a/dotfiles/nvim/lua/jodhus/settings.lua b/dotfiles/nvim/lua/jodhus/settings.lua new file mode 100644 index 0000000..b48d80e --- /dev/null +++ b/dotfiles/nvim/lua/jodhus/settings.lua @@ -0,0 +1,28 @@ +local global = vim.g +local o = vim.opt + +-- Editor options + +o.number = true +o.relativenumber = true +o.clipboard = "unnamedplus" +o.syntax = ON +o.autoindent = true +o.cursorline = true +o.expandtab = true +o.shiftwidth = 4 +o.tabstop = 4 +o.encoding = "UTF-8" +o.ruler = true +o.mouse = "a" +o.title = true +o.hidden = true +o.ttimeoutlen = 0 +o.wildmenu = true +o.showcmd = true +o.showmatch = true +o.inccommand = "split" +o.splitright = true +o.splitbelow = true +o.termguicolors = true +o.background = "dark"