diff options
author | Matthew Wozniak <me@woz.blue> | 2024-12-12 22:34:06 -0500 |
---|---|---|
committer | Matthew Wozniak <me@woz.blue> | 2024-12-12 22:39:08 -0500 |
commit | a7f3bc8f5d8e7fbb3e6b631f9898de3e7d3bba7b (patch) | |
tree | 86499eda0fe7761c0e1495bfa2a2b4901ff84b4f | |
download | nvim-master.tar.gz nvim-master.zip |
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | after/plugin/cfg.vim | 6 | ||||
-rw-r--r-- | after/plugin/fzf-lua.lua | 2 | ||||
-rw-r--r-- | after/plugin/lsp.lua | 79 | ||||
-rw-r--r-- | after/plugin/vimtex.vim | 2 | ||||
-rw-r--r-- | init.lua | 53 | ||||
-rw-r--r-- | lua/util.lua | 7 |
7 files changed, 150 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e033bc6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +lazy-lock.json diff --git a/after/plugin/cfg.vim b/after/plugin/cfg.vim new file mode 100644 index 0000000..9d95463 --- /dev/null +++ b/after/plugin/cfg.vim @@ -0,0 +1,6 @@ +set number +set autoindent +set sw=4 ts=4 noet tw=80 cc=80 +set spr sb pb=12 winbl=12 nowrap ruler autoread +set gfn=Hack:h10 noshowmode +colorscheme seoul256 diff --git a/after/plugin/fzf-lua.lua b/after/plugin/fzf-lua.lua new file mode 100644 index 0000000..d687fda --- /dev/null +++ b/after/plugin/fzf-lua.lua @@ -0,0 +1,2 @@ +require('util').nn('<leader>ff', '<cmd>FzfLua files<CR>') + diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua new file mode 100644 index 0000000..6eb1ebb --- /dev/null +++ b/after/plugin/lsp.lua @@ -0,0 +1,79 @@ +local lspconfig = require('lspconfig') +local cmp = require('cmp') +local cmp_lsp = require('cmp_nvim_lsp') + +local nn = require('util').nn + +cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + window = { + -- completion = cmp.config.window.bordered(), + -- documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + ['<C-b>'] = cmp.mapping.scroll_docs(-4), + ['<C-f>'] = cmp.mapping.scroll_docs(4), + ['<C-Space>'] = cmp.mapping.complete(), + ['<C-e>'] = cmp.mapping.abort(), + ['<Tab>'] = cmp.mapping.select_next_item(), + ['<S-Tab>'] = cmp.mapping.select_prev_item(), + -- Accept currently selected item. Set `select` to `false` to only + -- confirm explicitly selected items. + ['<Tab>'] = cmp.mapping.confirm({ select = true }), + }), + sources = { + { name = 'nvim_lsp' }, + { name = 'buffer' }, + { name = 'path' }, + -- For luasnip users. + { name = 'luasnip' }, + }, +}) + +-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline({ '/', '?' }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' } + } +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }), + matching = { disallow_symbol_nonprefix_matching = false } +}) + +local function onattach(client, buf) + nn("gD", vim.lsp.buf.declaration) + nn("gd", vim.lsp.buf.definition) + nn("<Leader>K", vim.lsp.buf.hover) + nn("gi", vim.lsp.buf.implementation) + nn("<C-k>", vim.lsp.buf.signature_help) + nn("<Leader>D", vim.lsp.buf.type_definition) + nn("<Leader>r", vim.lsp.buf.rename) + nn("<Leader>A", vim.lsp.buf.code_action) + nn("<Leader>R", vim.lsp.buf.references) + nn("<Leader>f", vim.lsp.buf.format) +end + +local caps = vim.lsp.protocol.make_client_capabilities() +caps = cmp_lsp.default_capabilities(caps) + +local servers = {'clangd', 'rust_analyzer', 'zls', 'texlab'} +for _, lsp in pairs(servers) do + lspconfig[lsp].setup { + capabilities = caps, + on_attach = onattach, + flags = { debounce_text_changes = 500 } + } +end diff --git a/after/plugin/vimtex.vim b/after/plugin/vimtex.vim new file mode 100644 index 0000000..c45ed12 --- /dev/null +++ b/after/plugin/vimtex.vim @@ -0,0 +1,2 @@ +let g:vimtex_view_method = 'zathura' + diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..0e85cb8 --- /dev/null +++ b/init.lua @@ -0,0 +1,53 @@ +-- 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) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + { + "ibhagwan/fzf-lua", + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = {}, + }, + { "m4xshen/autoclose.nvim", opts = {} }, + { "junegunn/seoul256.vim" }, + { "neovim/nvim-lspconfig" }, + { 'hrsh7th/cmp-nvim-lsp' }, + { 'hrsh7th/cmp-buffer' }, + { 'hrsh7th/cmp-path' }, + { 'hrsh7th/cmp-cmdline' }, + { 'hrsh7th/nvim-cmp' }, + { 'L3MON4D3/LuaSnip' }, + { 'lervag/vimtex', lazy = false }, + { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + opts = {}, + }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "seoul256" } }, + -- automatically check for plugin updates + checker = { enabled = true, notify = false }, +}) diff --git a/lua/util.lua b/lua/util.lua new file mode 100644 index 0000000..d1f08b8 --- /dev/null +++ b/lua/util.lua @@ -0,0 +1,7 @@ +local M = {} + +M.nn = function(lh, rh) + vim.keymap.set('n', lh, rh, { noremap = true, silent = true }) +end + +return M |