From 0181474d3142cb0f6c51b26910b7ed2e6f170753 Mon Sep 17 00:00:00 2001 From: Alexander Goussas Date: Wed, 25 Dec 2024 21:13:59 -0500 Subject: [PATCH] add nvim config --- Makefile.common | 1 + Makefile.macos | 4 +- nvim/.config/nvim/init.lua | 128 +++++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 Makefile.common create mode 100644 nvim/.config/nvim/init.lua diff --git a/Makefile.common b/Makefile.common new file mode 100644 index 0000000..1c9d7fc --- /dev/null +++ b/Makefile.common @@ -0,0 +1 @@ +PKGS_COMMON := nvim diff --git a/Makefile.macos b/Makefile.macos index 68754a4..eb2f328 100644 --- a/Makefile.macos +++ b/Makefile.macos @@ -1,4 +1,6 @@ -PKGS := yabai skhd +include Makefile.common + +PKGS := yabai skhd $(PKGS_COMMON) install: stow $(PKGS) diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..c0f02e3 --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1,128 @@ +vim.o.number = true +vim.o.signcolumn = 'yes' + +-- Splitting +vim.o.splitbelow = true +vim.o.splitright = true + +-- Indenting +vim.o.shiftwidth = 2 +vim.o.shiftround = true +vim.o.tabstop = 2 +vim.o.softtabstop = 2 +vim.o.expandtab = true + +vim.cmd('colorscheme zaibatsu') + +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({ + install = { colorscheme = { "zaibatsu" } }, + spec = { + { + 'ndmitchell/ghcid', + config = function(plugin) + vim.opt.rtp:append(plugin.dir .. "/plugins/nvim") + end + }, + { + 'nvim-telescope/telescope.nvim', + tag = '0.1.8', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + }, + config = function() + local telescope = require('telescope') + local builtin = require('telescope.builtin') + vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) + vim.keymap.set('n', 'fg', builtin.live_grep, { desc = 'Telescope live grep' }) + vim.keymap.set('n', 'fb', builtin.buffers, { desc = 'Telescope buffers' }) + + telescope.setup({ + defaults = { + sorting_strategy = "ascending", + layout_strategy = "bottom_pane", + wrap_results = true, + preview = false, + } + }) + end + }, + { + "miikanissi/modus-themes.nvim", + priority = 1000, + config = function() + vim.cmd[[colorscheme modus_vivendi]] + end + }, + { + 'nvim-treesitter/nvim-treesitter', + config = function() + require('nvim-treesitter.configs').setup({ + ensure_installed = { 'go', 'haskell', 'lua' }, + auto_install = false, + highlight = { enable = true }, + }) + end + }, + { + 'lewis6991/gitsigns.nvim', + config = function() + require('gitsigns').setup({ + signcolumn = true, + current_line_blame = true, + }) + end + }, + { + "neovim/nvim-lspconfig", + config = function() + -- Some mappings that LSP sets by default + -- grn -> rename + -- gra -> code action + -- grr -> references + -- gO -> document symbol + -- C-S -> signature help + + local lspconfig = require('lspconfig') + + -- Language servers + + lspconfig.gopls.setup({}) + + vim.api.nvim_create_autocmd('LspAttach', { + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + -- TODO: Check from which version is this API available + -- if client:supports_method('textDocument/completion') then + -- vim.lsp.completion.enable(true, client.id, args.buf, {autotrigger = true}) + -- end + if client:supports_method('textDocument/formatting') then + vim.api.nvim_create_autocmd('BufWritePre', { + buffer = args.buf, + callback = function() + vim.lsp.buf.format({bufnr = args.buf, id = client.id}) + end, + }) + end + end, + }) + end + } + }, +}) -- 2.43.0