From dadc8060ca958707bb574564702d79342c16e436 Mon Sep 17 00:00:00 2001 From: Fey Naomi Schrewe Date: Wed, 22 May 2024 20:28:03 +0200 Subject: [PATCH] feat: initial commit --- .envrc | 1 + default.nix | 4 +++ init.lua | 11 ++++++ lazy-lock.json | 28 +++++++++++++++ lua/.luarc.json | 21 +++++++++++ lua/cmp-setup.lua | 23 +++++++++++++ lua/lsp-setup.lua | 58 +++++++++++++++++++++++++++++++ lua/neovide.lua | 4 +++ lua/plugins.lua | 88 +++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 238 insertions(+) create mode 100644 .envrc create mode 100644 default.nix create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/.luarc.json create mode 100644 lua/cmp-setup.lua create mode 100644 lua/lsp-setup.lua create mode 100644 lua/neovide.lua create mode 100644 lua/plugins.lua diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..1d953f4 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..f8eba66 --- /dev/null +++ b/default.nix @@ -0,0 +1,4 @@ +{ pkgs ? import {} }: with pkgs; +mkShell { + buildInputs = [ lua-language-server ]; +} diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..81e751a --- /dev/null +++ b/init.lua @@ -0,0 +1,11 @@ +require 'plugins' + +if vim.g.neovide then + require 'neovide' +end + +vim.opt.number = true +vim.opt.tabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.expandtab = false +vim.opt.relativenumber = true diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..ec60a4d --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,28 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp-under-comparator": { "branch": "master", "commit": "6857f10272c3cfe930cece2afa2406e1385bfef8" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "diffview.nvim": { "branch": "main", "commit": "72c6983f422689f310b379a04fd555799b0d7cfc" }, + "direnv.vim": { "branch": "master", "commit": "ab2a7e08dd630060cd81d7946739ac7442a4f269" }, + "drex.nvim": { "branch": "main", "commit": "acccc1225e61a3977d86a590420b868e708cc64a" }, + "lazy.nvim": { "branch": "main", "commit": "8f19915175395680808de529e4220da8dafc0759" }, + "neodev.nvim": { "branch": "main", "commit": "ce9a2e8eaba5649b553529c5498acb43a6c317cd" }, + "neogit": { "branch": "master", "commit": "bc0c609e3568a171e0549b449aa1b2b4b5b20e8c" }, + "nvim-cmp": { "branch": "main", "commit": "5260e5e8ecadaf13e6b82cf867a909f54e15fd07" }, + "nvim-dap": { "branch": "master", "commit": "5a2f7121869394502521c52b2bc581ab22c69447" }, + "nvim-lspconfig": { "branch": "master", "commit": "eadcee1573ca9d0e0cd36a49f620186a8dfdc607" }, + "nvim-surround": { "branch": "main", "commit": "79aaa42da1f698ed31bcbe7f83081f69dca7ba17" }, + "nvim-test": { "branch": "main", "commit": "e06f3d029ee161f3ead6193cf27354d1eb8723c3" }, + "nvim-treesitter": { "branch": "master", "commit": "30de5e7e9486fb1b1b8c2a1e71052b13f94f1cb0" }, + "nvim-web-devicons": { "branch": "master", "commit": "e37bb1feee9e7320c76050a55443fa843b4b6f83" }, + "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, + "rose-pine": { "branch": "main", "commit": "b6fe88c3282cf9f117a3e836d761c2d78d02f417" }, + "rust-tools.nvim": { "branch": "master", "commit": "676187908a1ce35ffcd727c654ed68d851299d3e" }, + "suda.vim": { "branch": "master", "commit": "b97fab52f9cdeabe2bbb5eb98d82356899f30829" }, + "telescope.nvim": { "branch": "master", "commit": "4aed63995a69e343b068c7469491a8d1592c339f" } +} \ No newline at end of file diff --git a/lua/.luarc.json b/lua/.luarc.json new file mode 100644 index 0000000..8cbb39b --- /dev/null +++ b/lua/.luarc.json @@ -0,0 +1,21 @@ +{ + "workspace.library": [ + "/home/fey/.local/share/nvim/site/pack/packer/start/neodev.nvim/types/stable", + "/nix/store/ax8sn0k1ranydy6f6w21lcvszipc117z-neovim-unwrapped-0.9.1/share/nvim/runtime/lua", + "/home/fey/.local/share/nvim/site/pack/packer/opt/nvim-cmp/lua", + "/home/fey/.local/share/nvim/site/pack/packer/opt/nvim-lspconfig/lua", + "/home/fey/.local/share/nvim/site/pack/packer/start/LuaSnip/lua", + "/home/fey/.local/share/nvim/site/pack/packer/start/cmp-buffer/lua", + "/home/fey/.local/share/nvim/site/pack/packer/start/cmp-cmdline/lua", + "/home/fey/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp/lua", + "/home/fey/.local/share/nvim/site/pack/packer/start/cmp-path/lua", + "/home/fey/.local/share/nvim/site/pack/packer/start/cmp_luasnip/lua", + "/home/fey/.local/share/nvim/site/pack/packer/start/neodev.nvim/lua", + "/home/fey/.local/share/nvim/site/pack/packer/start/nvim-cmp/lua", + "/home/fey/.local/share/nvim/site/pack/packer/start/nvim-lspconfig/lua", + "/home/fey/.local/share/nvim/site/pack/packer/start/packer.nvim/lua", + "/home/fey/.local/share/nvim/site/pack/packer/start/rose-pine/lua", + "/home/fey/.config/nvim/lua", + "${3rd}/luv/library" + ] +} \ No newline at end of file diff --git a/lua/cmp-setup.lua b/lua/cmp-setup.lua new file mode 100644 index 0000000..be70a86 --- /dev/null +++ b/lua/cmp-setup.lua @@ -0,0 +1,23 @@ +local cmp = require 'cmp' + +cmp.setup({ + snippet = { + expand = function(args) + require('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.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'vsnip' }, -- For vsnip users. + { name = 'luasnip' }, -- For luasnip users. + }, { + { name = 'buffer' }, + }) +}) diff --git a/lua/lsp-setup.lua b/lua/lsp-setup.lua new file mode 100644 index 0000000..5f257bb --- /dev/null +++ b/lua/lsp-setup.lua @@ -0,0 +1,58 @@ +require('neodev').setup({}) + +local lspconfig = require('lspconfig') + +lspconfig.lua_ls.setup {} +lspconfig.tsserver.setup {} + +-- Global mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +vim.keymap.set('n', 'e', vim.diagnostic.open_float) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist) + +-- Use LspAttach autocommand to only map the following keys +-- after the language server attaches to the current buffer +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + -- Enable completion triggered by + vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local opts = { buffer = ev.buf } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, opts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) + vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', 'f', function() + vim.lsp.buf.format { async = true } + end, opts) + end, +}) + +local rt = require("rust-tools") + +rt.setup({ + server = { + on_attach = function(_, bufnr) + -- Hover actions + vim.keymap.set("n", "", rt.hover_actions.hover_actions, { buffer = bufnr }) + -- Code action groups + vim.keymap.set("n", "a", rt.code_action_group.code_action_group, { buffer = bufnr }) + end, + }, +}) + diff --git a/lua/neovide.lua b/lua/neovide.lua new file mode 100644 index 0000000..c155037 --- /dev/null +++ b/lua/neovide.lua @@ -0,0 +1,4 @@ +vim.o.guifont = "Monoid Nerd Font:h12" +vim.g.neovide_scale_factor = 0.75 +vim.g.neovide_cursor_animation_length = 0 + diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..39c1ab7 --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,88 @@ +-- bootstrap lazy +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", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +return require('lazy').setup { + spec = { + { + 'rose-pine/neovim', + name = 'rose-pine', + config = function() vim.cmd [[colorscheme rose-pine-moon]] end + }, + { + "L3MON4D3/LuaSnip", + version = "v2.*", + build = "make install_jsregexp" + }, + 'saadparwaiz1/cmp_luasnip', + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', + { + 'hrsh7th/nvim-cmp', + config = function() require 'cmp-setup' end + }, + "lukas-reineke/cmp-under-comparator", + 'folke/neodev.nvim', + { 'neovim/nvim-lspconfig', config = function() require 'lsp-setup' end, after = 'neodev.nvim' }, + 'simrat39/rust-tools.nvim', + 'mfussenegger/nvim-dap', + { + 'numToStr/Comment.nvim', + config = function() + require('Comment').setup() + end + }, + { + "NeogitOrg/neogit", + version = "v0.0.1", + dependencies = { + "nvim-lua/plenary.nvim", -- required + "nvim-telescope/telescope.nvim", -- optional + "sindrets/diffview.nvim", -- optional + }, + config = true, + }, + 'lambdalisue/suda.vim', + { + "kylechui/nvim-surround", + version = "*", -- Use for stability; omit to use `main` branch for the latest features + config = function() + require("nvim-surround").setup({}) + end + }, + { + 'nvim-treesitter/nvim-treesitter', + config = function() require 'nvim-treesitter.configs'.setup({}) end, + build = function() + local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) + ts_update() + end, + }, + { + 'theblob42/drex.nvim', + dependencies = 'kyazdani42/nvim-web-devicons', + config = function() + vim.keymap.set('n', '', ':DrexDrawerToggle') + end + }, + { + "klen/nvim-test", + config = function() + require('nvim-test').setup() + end + }, + 'direnv/direnv.vim' + } +}