diff options
| -rw-r--r-- | .stowrc | 1 | ||||
| -rw-r--r-- | README.md | 20 | ||||
| -rw-r--r-- | editorconfig/.editorconfig | 26 | ||||
| -rw-r--r-- | nvim/.config/nvim/after/syntax/markdown.vim | 1 | ||||
| -rw-r--r-- | nvim/.config/nvim/init.lua | 102 | ||||
| -rw-r--r-- | nvim/.config/nvim/lazy-lock.json | 12 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/plugins/lsp.lua | 18 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/plugins/neo-tree.lua | 23 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/plugins/telescope.lua | 9 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/plugins/treesitter.lua | 16 | ||||
| -rw-r--r-- | tmux/.config/tmux/tmux.conf | 25 |
11 files changed, 253 insertions, 0 deletions
@@ -0,0 +1 @@ +--target=$HOME diff --git a/README.md b/README.md new file mode 100644 index 0000000..31c7eb8 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# dotfiles + +Configs for editorconfig, tmux, and NeoVim. Managed with GNU Stow. + +## Install on a new machine + +```sh +git clone <this-repo> ~/src/dotfiles +cd ~/src/dotfiles +stow editorconfig tmux nvim +``` + +Stow reads the target (`$HOME`) from `.stowrc`. + +NeoVim installs its own plugins and language servers on first start. + +## Notes + +- The tmux status color `#272c2e` matches a terminal background of + `#2E3436`. Adjust it on machines with a different terminal theme. diff --git a/editorconfig/.editorconfig b/editorconfig/.editorconfig new file mode 100644 index 0000000..233b465 --- /dev/null +++ b/editorconfig/.editorconfig @@ -0,0 +1,26 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[Makefile] +indent_style = tab + +[{*.go,go.mod}] +indent_style = tab + +[{*.rb,*.rake,Rakefile,Gemfile,*.gemspec,config.ru}] +indent_size = 2 + +[*.{html,css}] +indent_size = 2 + +[*.{yml,yaml}] diff --git a/nvim/.config/nvim/after/syntax/markdown.vim b/nvim/.config/nvim/after/syntax/markdown.vim new file mode 100644 index 0000000..d9b0a80 --- /dev/null +++ b/nvim/.config/nvim/after/syntax/markdown.vim @@ -0,0 +1 @@ +syn clear markdownError diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..f621504 --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1,102 @@ +-- Basic options +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +vim.opt.number = true +vim.opt.relativenumber = false +vim.opt.mouse = "a" +vim.opt.ignorecase = true +vim.opt.smartcase = true +vim.opt.expandtab = true +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.tabstop = 4 +vim.opt.autoindent = true +vim.opt.cindent = true +vim.opt.signcolumn = "yes" +vim.opt.termguicolors = true +vim.opt.splitright = true +vim.opt.splitbelow = true +vim.opt.clipboard = "unnamedplus" +vim.opt.undofile = true +vim.opt.cursorline = true +vim.opt.background="dark" +vim.opt.completeopt = { "menuone", "noinsert", "popup" } + +vim.cmd.colorscheme("habamax") + +-- Diagnostics: show messages as virtual text, no fancy UI +vim.diagnostic.config({ + virtual_text = true, + severity_sort = true, +}) + +-- Native LSP completion (NeoVim 0.11+), no completion plugin needed +vim.api.nvim_create_autocmd("LspAttach", { + callback = function(ev) + local client = vim.lsp.get_client_by_id(ev.data.client_id) + if client and client:supports_method("textDocument/completion") then + vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true }) + end + end, +}) + +vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Go to definition" }) + +-- Go convention: organize imports and format on save (via gopls) +vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + local client = vim.lsp.get_clients({ bufnr = 0, name = "gopls" })[1] + if not client then + return + end + local params = vim.lsp.util.make_range_params(0, client.offset_encoding) + params.context = { only = { "source.organizeImports" } } + local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 2000) + for _, res in pairs(result or {}) do + for _, action in pairs(res.result or {}) do + if action.edit then + vim.lsp.util.apply_workspace_edit(action.edit, client.offset_encoding) + end + end + end + vim.lsp.buf.format() + end, +}) + +-- Spell checking for markdown and git commit messages +vim.api.nvim_create_autocmd("FileType", { + pattern = { "markdown", "gitcommit" }, + callback = function() + vim.opt_local.spell = true + vim.opt_local.spelllang = "en_us" + end, +}) + + +-- 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) + +-- Setup lazy.nvim (loads all files in lua/plugins/) +require("lazy").setup({ + spec = { + { import = "plugins" }, + }, + install = { colorscheme = { "habamax" } }, + checker = { enabled = true, notify = false }, +}) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..c2c2f1a --- /dev/null +++ b/nvim/.config/nvim/lazy-lock.json @@ -0,0 +1,12 @@ +{ + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "67029ccdac1ef8941e13b826417bc0ffac24cc86" }, + "mason.nvim": { "branch": "main", "commit": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "ebd66767191714e008ce73b769518a763ff31bdc" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-lspconfig": { "branch": "master", "commit": "1c0d8f70dbc8827263eedc3cf7021ceba0f68689" }, + "nvim-treesitter": { "branch": "master", "commit": "cf12346a3414fa1b06af75c79faebe7f76df080a" }, + "nvim-web-devicons": { "branch": "master", "commit": "2ae6958df7ced50baac5035cec0c15799eedfbf7" }, + "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, + "telescope.nvim": { "branch": "master", "commit": "427b576c16792edad01a92b89721d923c19ad60f" } +} diff --git a/nvim/.config/nvim/lua/plugins/lsp.lua b/nvim/.config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..15933fa --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,18 @@ +return { + { + "mason-org/mason.nvim", + opts = {}, + }, + { + -- Installs language servers and enables them automatically. + -- Add "clangd" to ensure_installed for C/C++ later. + "mason-org/mason-lspconfig.nvim", + dependencies = { + "mason-org/mason.nvim", + "neovim/nvim-lspconfig", + }, + opts = { + ensure_installed = { "gopls", "pyright" }, + }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/neo-tree.lua b/nvim/.config/nvim/lua/plugins/neo-tree.lua new file mode 100644 index 0000000..eba00dd --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/neo-tree.lua @@ -0,0 +1,23 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + "nvim-tree/nvim-web-devicons", + }, + lazy = false, + keys = { + { "<leader>e", "<Cmd>Neotree toggle float<CR>", desc = "Toggle Neo-tree" }, + }, + opts = { + close_if_last_window = true, + filesystem = { + follow_current_file = { enabled = true }, + use_libuv_file_watcher = true, + }, + window = { + position = "float", + }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/telescope.lua b/nvim/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..76f77c2 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,9 @@ +return { + "nvim-telescope/telescope.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + keys = { + { "<leader>ff", "<cmd>Telescope find_files<cr>", desc = "Find files" }, + { "<leader>fg", "<cmd>Telescope live_grep<cr>", desc = "Search in files" }, + { "<leader>fb", "<cmd>Telescope buffers<cr>", desc = "Open buffers" }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/treesitter.lua b/nvim/.config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..9692f57 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,16 @@ +return { + "nvim-treesitter/nvim-treesitter", + branch = "master", + build = ":TSUpdate", + config = function() + require("nvim-treesitter.configs").setup({ + ensure_installed = { + "python", "go", "gomod", "gosum", + "lua", "vim", "vimdoc", + "markdown", "markdown_inline", "yaml", + }, + highlight = { enable = true }, + indent = { enable = true }, + }) + end, +} diff --git a/tmux/.config/tmux/tmux.conf b/tmux/.config/tmux/tmux.conf new file mode 100644 index 0000000..c5e339c --- /dev/null +++ b/tmux/.config/tmux/tmux.conf @@ -0,0 +1,25 @@ +# True color and fast Esc for NeoVim +set -g default-terminal "tmux-256color" +set -as terminal-features ",*:RGB" +set -sg escape-time 10 +set -g focus-events on + +set-option -g prefix M-m +unbind-key C-b +bind-key M-m send-prefix + +set -g base-index 1 +set -g pane-base-index 1 + +# Alt+1..5: switch to window without prefix +bind -n M-1 select-window -t 1 +bind -n M-2 select-window -t 2 +bind -n M-3 select-window -t 3 +bind -n M-4 select-window -t 4 +bind -n M-5 select-window -t 5 + +set -g status-left "" +set -g status-right "" +# Pseudo shadow: one step darker than the terminal background (#2E3436) +set -g status-style bg=#272c2e,fg=colour244 +set -g window-status-current-style fg=colour250,bold |
