commit f5f788557801dc58497fab6395aa65045c4ef11d Author: Louis Hollingworth Date: Wed May 22 17:11:29 2024 +0100 Initial commit, added nvim diff --git a/README.md b/README.md new file mode 100644 index 0000000..9f00325 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Dots +My dot files, to be managed with GNU Stow. diff --git a/nvim/.config/nvim/after/plugin/lsp.lua b/nvim/.config/nvim/after/plugin/lsp.lua new file mode 100644 index 0000000..0817d6b --- /dev/null +++ b/nvim/.config/nvim/after/plugin/lsp.lua @@ -0,0 +1,173 @@ +local keymap = vim.keymap.set + +require('mason').setup({ + ui = { + icons = { + server = " ", + lsp = " ", + linter = " ", + formatter = " ", + + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + }, + }, +}) + +require("mason-lspconfig").setup({ + automatic_installation = true, +}) + +local lsp = require('lspconfig') + +local cmp = require('cmp') +local cmp_select = {behavior = cmp.SelectBehavior.Select} + +local opts = { noremap=true, silent=true } +--keymap('i', '', vim.diagnostic.open_float, opts) +--keymap('i', '', vim.diagnostic.goto_prev, opts) +--keymap('i', '', vim.diagnostic.goto_next, opts) +--keymap('i', '', cmp.mapping.complete(), opts) +--keymap('i', '', vim.diagnostic.setloclist, opts) +keymap('n', '', vim.diagnostic.open_float, opts) +keymap('n', '', vim.diagnostic.goto_prev, opts) +keymap('n', '', vim.diagnostic.goto_next, opts) +--keymap('i', '', cmp.mapping.complete(), opts) +keymap('n', '', vim.diagnostic.setloclist, opts) + +cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + mapping = { + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.complete(cmp_select), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'buffer' }, + }, +}) + +vim.diagnostic.config({ + virtual_text = true, +}) + +local on_attach = function(client, bufnr) + local function buf_set_keymap(...) + vim.api.nvim_buf_set_keymap(bufnr, ...) + end + + -- Mappings. + local opts = { noremap = true, silent = true, buffer = bufnr} + + -- See `:help vim.lsp.*` for documentation on any of the below functions + vim.keymap.set("n", "gd", "Telescope lsp_definitions", opts) + vim.keymap.set("n", "gr", "Telescope lsp_references", opts) + + vim.keymap.set("n", "", "Telescope lsp_document_symbols", opts) + vim.keymap.set("n", "", "lua vim.lsp.buf.signature_help()", opts) + + vim.keymap.set("n", "gi", "Telescope lsp_implementations", opts) + vim.keymap.set("n", "K", "lua vim.lsp.buf.hover()", opts) + vim.keymap.set("n", "D", "Telescope lsp_type_definitions", opts) + vim.keymap.set("n", "rn", "lua vim.lsp.buf.rename()", opts) + vim.keymap.set("n", "ca", "Telescope lsp_code_actions", opts) + vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, {buffer=0}) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, {buffer=0}) + vim.keymap.set("n", "dj", vim.diagnostic.goto_next, {buffer=0}) + vim.keymap.set("n", "dk", vim.diagnostic.goto_prev, {buffer=0}) + vim.keymap.set("n", "dl", "Telescope diagnostics", {buffer=0}) + vim.keymap.set("n", "r", vim.lsp.buf.rename, {buffer=0}) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, {buffer=0}) + + -- Set autocommands conditional on server_capabilities + if client.server_capabilities.document_highlight then + vim.cmd([[ + augroup lsp_document_highlight + autocmd! * + autocmd CursorHold lua vim.lsp.buf.document_highlight() + autocmd CursorMoved lua vim.lsp.buf.clear_references() + augroup END + ]]) + end +end + +lsp.gopls.setup({ + on_attach = on_attach, + flags = lsp_flags, + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + }, + }, +}) + +lsp['lua_ls'].setup{ + on_attach = on_attach, + flags = lsp_flags, +} + +lsp['rust_analyzer'].setup{ + on_attach = on_attach, + flags = lsp_flags, + cmd = { + "rustup", "run", "stable", "rust-analyzer", + }, + settings = { + ["rust-analyzer"] = { + procMacro = { + ignored = { + leptos_macro = { + "island", + "server", + }, + }, + }, + }, + }, +} + +lsp.clangd.setup{ + on_attach = on_attach, + flags = lsp_flags, +} + +lsp.emmet_ls.setup({ + -- on_attach = on_attach, + capabilities = capabilities, + filetypes = { "css", "eruby", "html", "javascript", "javascriptreact", "less", "sass", "scss", "svelte", "pug", "typescriptreact", "vue" }, + init_options = { + html = { + options = { + -- For possible options, see: https://github.com/emmetio/emmet/blob/master/src/config.ts#L79-L267 + ["bem.enabled"] = true, + }, + }, + } +}) +lsp.tsserver.setup{ + on_attach = on_attach, + flags = lsp_flags, +} + +lsp.zls.setup{ + capabilities = capabilities, + flags = lsp_flags, + on_attach = on_attach, +} + +lsp.texlab.setup {} diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..884e86d --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1 @@ +require("lucxjo") diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..0fa7396 --- /dev/null +++ b/nvim/.config/nvim/lazy-lock.json @@ -0,0 +1,39 @@ +{ + "LuaSnip": { "branch": "master", "commit": "b152822e1a4bafb6bdf11a16cc26525cbd95ee00" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "editorconfig-vim": { "branch": "master", "commit": "8b7da79e9daee7a3f3a8d4fe29886b9756305aff" }, + "formatter.nvim": { "branch": "master", "commit": "ad246d34ce7a32f752071ed81b09b94e6b127fad" }, + "friendly-snippets": { "branch": "main", "commit": "d5f74ce4dfdd82848f3f4eac65fe6e29ac5df4c2" }, + "gitsigns.nvim": { "branch": "main", "commit": "790355f00af1fc2c330ea1b2b7f68d65f19b57c9" }, + "glow.nvim": { "branch": "main", "commit": "238070a686c1da3bccccf1079700eb4b5e19aea4" }, + "headlines.nvim": { "branch": "master", "commit": "618ef1b2502c565c82254ef7d5b04402194d9ce3" }, + "lazy.nvim": { "branch": "main", "commit": "3f13f080434ac942b150679223d54f5ca91e0d52" }, + "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, + "lspsaga.nvim": { "branch": "main", "commit": "052234296f13e2705d5d290c7bd5a36d3dd81fde" }, + "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "273fdde8ac5e51f3a223ba70980e52bbc09d9f6f" }, + "mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" }, + "noice.nvim": { "branch": "main", "commit": "0cbe3f88d038320bdbda3c4c5c95f43a13c3aa12" }, + "nord.nvim": { "branch": "master", "commit": "80c1e5321505aeb22b7a9f23eb82f1e193c12470" }, + "nui.nvim": { "branch": "main", "commit": "cbd2668414331c10039278f558630ed19b93e69b" }, + "nvim-cmp": { "branch": "main", "commit": "8f3c541407e691af6163e2447f3af1bd6e17f9a3" }, + "nvim-dap": { "branch": "master", "commit": "6ae8a14828b0f3bff1721a35a1dfd604b6a933bb" }, + "nvim-dap-ui": { "branch": "master", "commit": "5934302d63d1ede12c0b22b6f23518bb183fc972" }, + "nvim-lint": { "branch": "master", "commit": "861a04313501563bb1b11f125ae9b7237a517b9b" }, + "nvim-lspconfig": { "branch": "master", "commit": "aa5f4f4ee10b2688fb37fa46215672441d5cd5d9" }, + "nvim-notify": { "branch": "master", "commit": "5371f4bfc1f6d3adf4fe9d62cd3a9d44356bfd15" }, + "nvim-treesitter": { "branch": "master", "commit": "1a4274c9e1226fb4c2009f4c0c3521b1931b0c5c" }, + "nvim-web-devicons": { "branch": "master", "commit": "794bba734ec95eaff9bb82fbd112473be2087283" }, + "oil.nvim": { "branch": "master", "commit": "f3a31eba24587bc038592103d8f7e64648292115" }, + "plenary.nvim": { "branch": "master", "commit": "08e301982b9a057110ede7a735dd1b5285eb341f" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, + "telescope.nvim": { "branch": "master", "commit": "35f94f0ef32d70e3664a703cefbe71bd1456d899" }, + "todo-comments.nvim": { "branch": "main", "commit": "a7e39ae9e74f2c8c6dc4eea6d40c3971ae84752d" }, + "undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" }, + "vim-grammarous": { "branch": "master", "commit": "db46357465ce587d5325e816235b5e92415f8c05" }, + "vim-wakatime": { "branch": "master", "commit": "3cb40867cb5a3120f9bef76eff88edc7f1dc1a23" }, + "vimtex": { "branch": "master", "commit": "a80934749c69cc6875b3c9b13ef59573a4824fb2" } +} \ No newline at end of file diff --git a/nvim/.config/nvim/lua/lucxjo/init.lua b/nvim/.config/nvim/lua/lucxjo/init.lua new file mode 100644 index 0000000..15a5b2e --- /dev/null +++ b/nvim/.config/nvim/lua/lucxjo/init.lua @@ -0,0 +1,43 @@ +require("lucxjo.keys") +require("lucxjo.lazy") +require("lucxjo.opts") + +local augroup = vim.api.nvim_create_augroup +local lucxjo_group = augroup('lucxjo', {}) + +local aucmd = vim.api.nvim_create_autocmd +local yank_group = augroup('HlYank', {}) + +aucmd('TextYankPost', { + group = yank_group, + pattern = '*', + callback = function() + vim.highlight.on_yank({ + higroup = 'IncSearch', + timeout = 40, + }) + end, +}) + +aucmd({"BufWritePre"}, { + group = lucxjo_group, + pattern = "*", + command = [[%s/\s\+$//e]], +}) + +aucmd('LspAttach', { + group = lucxjo, + callback = function(e) + local opts = { buffer = e.buf } + vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) + vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) + vim.keymap.set("n", "vws", function() vim.lsp.buf.workspace_symbol() end, opts) + vim.keymap.set("n", "vd", function() vim.diagnostic.open_float() end, opts) + vim.keymap.set("n", "vca", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "vrr", function() vim.lsp.buf.references() end, opts) + vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) + vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, opts) + vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts) + vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts) + end +}) diff --git a/nvim/.config/nvim/lua/lucxjo/keys.lua b/nvim/.config/nvim/lua/lucxjo/keys.lua new file mode 100644 index 0000000..57e826c --- /dev/null +++ b/nvim/.config/nvim/lua/lucxjo/keys.lua @@ -0,0 +1,13 @@ +vim.g.mapleader = " " + +local map = vim.api.nvim_set_keymap + +map("n", "p", ":Glow", {}) +map("n", "ch", ":nohl", { silent = true }) + +-- File management +map("n", "s", ":w", { silent = true}) +map("n", "q", ":q", {}) +map("n", "Q", ":q!", {}) +map("n", "S", ":wq", {}) +map("n", "fp", ":Oil", {}) diff --git a/nvim/.config/nvim/lua/lucxjo/lazy.lua b/nvim/.config/nvim/lua/lucxjo/lazy.lua new file mode 100644 index 0000000..8072885 --- /dev/null +++ b/nvim/.config/nvim/lua/lucxjo/lazy.lua @@ -0,0 +1,14 @@ +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) + +require("lazy").setup("lucxjo.plugins") diff --git a/nvim/.config/nvim/lua/lucxjo/opts.lua b/nvim/.config/nvim/lua/lucxjo/opts.lua new file mode 100644 index 0000000..f603701 --- /dev/null +++ b/nvim/.config/nvim/lua/lucxjo/opts.lua @@ -0,0 +1,39 @@ +local opt = vim.opt + +-- Context +opt.colorcolumn = "80" +opt.number = true +opt.relativenumber = true +opt.scrolloff = 4 +opt.signcolumn = "yes" + +-- Filetypes +opt.encoding = "utf8" +opt.fileencoding = "utf8" + +-- Theme +opt.syntax = "ON" +opt.termguicolors = true + +-- Search +opt.ignorecase = true +opt.smartcase = true +opt.incsearch = true +opt.hlsearch = true + +-- Whitespace +opt.expandtab = true +opt.shiftwidth = 4 +opt.softtabstop = 4 +opt.tabstop = 4 +opt.smartindent = true + +-- Undo +opt.undodir = os.getenv("HOME") .. "/.vim/undodir" +opt.undofile = true + +-- Misc +opt.backspace = "indent,eol,start" +opt.clipboard:append("unnamedplus") +opt.iskeyword:append("-") +vim.cmd[[colorscheme nord]] diff --git a/nvim/.config/nvim/lua/lucxjo/plugins/init.lua b/nvim/.config/nvim/lua/lucxjo/plugins/init.lua new file mode 100644 index 0000000..e53195b --- /dev/null +++ b/nvim/.config/nvim/lua/lucxjo/plugins/init.lua @@ -0,0 +1,87 @@ +return { + { + 'shaunsingh/nord.nvim', + lazy = false, + priority = 1000, + dependencies = "lukas-reineke/headlines.nvim", + config = function() + require("headlines").setup({ + markdown = { + headline_highlights = { + "Headline1", + "Headline2", + "Headline3", + "Headline4", + "Headline5", + "Headline6", + }, + codeblock_highlight = "CodeBlock", + dash_highlight = "Dash", + quote_highlight = "Quote", + }, + }) + end, + }, + { + "lukas-reineke/headlines.nvim", + dependencies = "nvim-treesitter/nvim-treesitter", + config = true, -- or `opts = {}` + }, + "editorconfig/editorconfig-vim", + { + "ellisonleao/glow.nvim", + config = function() require("glow").setup() end, + }, + { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() require("lualine").setup{ + options = { + theme = "nord", + }, + } end, + }, + "wakatime/vim-wakatime", + { + "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = {}, + }, + "nvim-tree/nvim-web-devicons", + "mbbill/undotree", + { + "lewis6991/gitsigns.nvim", + config = function () + require("gitsigns").setup() + end, + }, + { + "folke/noice.nvim", + event = "VeryLazy", + opts = { + -- add any options here + }, + dependencies = { + -- if you lazy-load any plugin below, make sure to add proper `module="..."` entries + "MunifTanjim/nui.nvim", + -- OPTIONAL: + -- `nvim-notify` is only needed, if you want to use the notification view. + -- If not available, we use `mini` as the fallback + "rcarriga/nvim-notify", + } + }, + { + 'stevearc/oil.nvim', + opts = { + default_file_explorer = true, + constrain_cursor = "name", + view_options = { + -- Show files and directories that start with "." + show_hidden = true, + } + }, + -- Optional dependencies + dependencies = { "nvim-tree/nvim-web-devicons" }, + }, + 'rhysd/vim-grammarous', +} diff --git a/nvim/.config/nvim/lua/lucxjo/plugins/lsp.lua b/nvim/.config/nvim/lua/lucxjo/plugins/lsp.lua new file mode 100644 index 0000000..7653cd0 --- /dev/null +++ b/nvim/.config/nvim/lua/lucxjo/plugins/lsp.lua @@ -0,0 +1,63 @@ +return { + -- Autocomplete + "hrsh7th/nvim-cmp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + + -- Snippets + { + "L3MON4D3/LuaSnip", + build = "make install_jsregexp", + }, + "saadparwaiz1/cmp_luasnip", + "rafamadriz/friendly-snippets", + + -- Manage + { + "williamboman/mason.nvim", + config = function() require("mason").setup() end, + }, + { + "williamboman/mason-lspconfig.nvim", + config = function() require("mason-lspconfig").setup() end, + }, + + -- Configure + "neovim/nvim-lspconfig", + "hrsh7th/cmp-nvim-lsp", + "glepnir/lspsaga.nvim", + "onsails/lspkind.nvim", + + -- Lint + { + "mfussenegger/nvim-lint", + config = function() + require("lint").linters_by_ft = { + go = {'golangclient'}, + lua = {'luacheck'}, + sh = {'shellcheck'}, + c = {'cpplint'} + } + end, + }, + + -- Format + { + "mhartington/formatter.nvim", + config = function() + require("formatter").setup() + end, + }, + + -- DAP + { + "rcarriga/nvim-dap-ui", + dependencies = {"mfussenegger/nvim-dap"} + }, + { + 'lervag/vimtex', + config = function() + vim.g.vimtex_view_method = "zathura" + end, + } +} diff --git a/nvim/.config/nvim/lua/lucxjo/plugins/telescope.lua b/nvim/.config/nvim/lua/lucxjo/plugins/telescope.lua new file mode 100644 index 0000000..ad9b155 --- /dev/null +++ b/nvim/.config/nvim/lua/lucxjo/plugins/telescope.lua @@ -0,0 +1,20 @@ +return { + { + 'nvim-telescope/telescope.nvim', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope-fzf-native.nvim', + }, + config = function() + local builtin = require('telescope.builtin') + vim.keymap.set('n', 'ff', builtin.find_files, {}) + vim.keymap.set('n', 'fg', builtin.live_grep, {}) + vim.keymap.set('n', 'fb', builtin.buffers, {}) + vim.keymap.set('n', 'fh', builtin.help_tags, {}) + end, + }, + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' + }, +} diff --git a/nvim/.config/nvim/lua/lucxjo/plugins/treesitter.lua b/nvim/.config/nvim/lua/lucxjo/plugins/treesitter.lua new file mode 100644 index 0000000..fb3d476 --- /dev/null +++ b/nvim/.config/nvim/lua/lucxjo/plugins/treesitter.lua @@ -0,0 +1,12 @@ +return { + "nvim-treesitter/nvim-treesitter", + config = function() + require('nvim-treesitter.install').update({ with_sync = true }) + require('nvim-treesitter.configs').setup({ + highlight = { + enable = true, + diable = { "latex" }, + } + }) + end, +} diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..c85ab03 --- /dev/null +++ b/setup.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +# what directories should be installable by all users including the root user +base=( +) + +# folders that should, or only need to be installed for a local user +useronly=( + nvim +) + +# run the stow command for the passed in directory ($2) in location $1 +stowit() { + usr=$1 + app=$2 + # -v verbose + # -R recursive + # -t target + stow -v -R -t ${usr} ${app} +} + +echo "" +echo "Stowing apps for user: ${whoami}" + +# install apps available to local users and root +for app in ${base[@]}; do + stowit "${HOME}" $app +done + +# install only user space folders +for app in ${useronly[@]}; do + if [[! "$(whoami)" = *"root"*]]; then + stowit "${HOME}" $app + fi +done + +echo "" +echo "##### ALL DONE"