From 341c3be75228dbd23fd05208d148acecf950d573 Mon Sep 17 00:00:00 2001
From: Jacob Janzen <jjanzenn@proton.me>
Date: Wed, 7 Aug 2024 14:58:48 -0500
Subject: initial commit

---
 config/nvim/init.org                | 37 +++++++++++++++
 config/nvim/lua/appearance.org      | 15 ++++++
 config/nvim/lua/autocomplete.org    | 57 +++++++++++++++++++++++
 config/nvim/lua/behaviour.org       | 19 ++++++++
 config/nvim/lua/format.org          | 25 ++++++++++
 config/nvim/lua/languageServers.org | 92 +++++++++++++++++++++++++++++++++++++
 config/nvim/lua/plugins.org         | 49 ++++++++++++++++++++
 7 files changed, 294 insertions(+)
 create mode 100644 config/nvim/init.org
 create mode 100644 config/nvim/lua/appearance.org
 create mode 100644 config/nvim/lua/autocomplete.org
 create mode 100644 config/nvim/lua/behaviour.org
 create mode 100644 config/nvim/lua/format.org
 create mode 100644 config/nvim/lua/languageServers.org
 create mode 100644 config/nvim/lua/plugins.org

(limited to 'config/nvim')

diff --git a/config/nvim/init.org b/config/nvim/init.org
new file mode 100644
index 0000000..703e8e2
--- /dev/null
+++ b/config/nvim/init.org
@@ -0,0 +1,37 @@
+#+title: Neovim Settings
+This is the entry point for my Neovim configuration.
+
+Disable timeout to speed things up.
+#+begin_src lua :tangle yes
+vim.cmd([[set notimeout]])
+#+end_src
+
+Install plugins in the [[./lua/plugins.org][plugins.lua]] file.
+#+begin_src lua :tangle yes
+require('plugins')
+#+end_src
+
+Set up behaviour in the [[./lua/behaviour.org][behaviour.lua]] file.
+#+begin_src lua :tangle yes
+require('behaviour')
+#+end_src
+
+Set up appearance in the [[./lua/appearance.org][appearance.lua]] file.
+#+begin_src lua :tangle yes
+require('appearance')
+#+end_src
+
+Set up formatting options in the [[./lua/format.org][format.lua]] file.
+#+begin_src lua :tangle yes
+require('format')
+#+end_src
+
+Set up language servers in the [[./lua/languageServers.org][languageServers.lua]] file.
+#+begin_src lua :tangle yes
+require('languageServers')
+#+end_src
+
+Set up auto-complete in the [[./lua/autocomplete.org][autocomplete.lua]] file.
+#+begin_src lua :tangle yes
+require('autocomplete')
+#+end_src
diff --git a/config/nvim/lua/appearance.org b/config/nvim/lua/appearance.org
new file mode 100644
index 0000000..6cbf4ba
--- /dev/null
+++ b/config/nvim/lua/appearance.org
@@ -0,0 +1,15 @@
+#+title: Neovim Appearance Settings
+Use line numbers.
+#+begin_src lua :tangle yes
+  vim.opt.number = true
+#+end_src
+
+Set colour scheme.
+#+begin_src lua :tangle yes
+  vim.cmd([[
+      set termguicolors
+      let ayucolor="light"
+      syntax on
+      colorscheme ayu
+  ]])
+#+end_src
diff --git a/config/nvim/lua/autocomplete.org b/config/nvim/lua/autocomplete.org
new file mode 100644
index 0000000..505e93c
--- /dev/null
+++ b/config/nvim/lua/autocomplete.org
@@ -0,0 +1,57 @@
+#+title: Neovim Auto-complete Settings
+Set up auto-completion with LSP.
+#+begin_src lua :tangle yes
+  local capabilities = require("cmp_nvim_lsp").default_capabilities()
+
+  local lspconfig = require('lspconfig')
+
+  local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver' }
+  for _, lsp in ipairs(servers) do
+    lspconfig[lsp].setup {
+      -- on_attach = my_custom_on_attach,
+      capabilities = capabilities,
+    }
+  end
+
+  local luasnip = require 'luasnip'
+
+  local cmp = require 'cmp'
+  cmp.setup {
+    snippet = {
+      expand = function(args)
+        luasnip.lsp_expand(args.body)
+      end,
+    },
+    mapping = cmp.mapping.preset.insert({
+      ['<C-d>'] = cmp.mapping.scroll_docs(-4),
+      ['<C-f>'] = cmp.mapping.scroll_docs(4),
+      ['<C-Space>'] = cmp.mapping.complete(),
+      ['<CR>'] = cmp.mapping.confirm {
+        behavior = cmp.ConfirmBehavior.Replace,
+        select = true,
+      },
+      ['<Tab>'] = cmp.mapping(function(fallback)
+        if cmp.visible() then
+          cmp.select_next_item()
+        elseif luasnip.expand_or_jumpable() then
+          luasnip.expand_or_jump()
+        else
+          fallback()
+        end
+      end, { 'i', 's' }),
+      ['<S-Tab>'] = cmp.mapping(function(fallback)
+        if cmp.visible() then
+          cmp.select_prev_item()
+        elseif luasnip.jumpable(-1) then
+          luasnip.jump(-1)
+        else
+          fallback()
+        end
+      end, { 'i', 's' }),
+    }),
+    sources = {
+      { name = 'nvim_lsp' },
+      { name = 'luasnip' },
+    },
+  }
+#+end_src
diff --git a/config/nvim/lua/behaviour.org b/config/nvim/lua/behaviour.org
new file mode 100644
index 0000000..d843d7b
--- /dev/null
+++ b/config/nvim/lua/behaviour.org
@@ -0,0 +1,19 @@
+#+title: Neovim Behaviour Settings
+
+Use tabs with width 4.
+#+begin_src lua :tangle yes
+  vim.opt.tabstop = 4
+  vim.opt.expandtab = true
+  vim.opt.shiftwidth = 4
+  vim.opt.autoindent = true
+#+end_src
+
+Better command line completion.
+#+begin_src lua :tangle yes
+  vim.opt.wildmode = 'longest,list'
+#+end_src
+
+Better management of file types.
+#+begin_src lua :tangle yes
+  vim.cmd('filetype plugin indent on')
+#+end_src
diff --git a/config/nvim/lua/format.org b/config/nvim/lua/format.org
new file mode 100644
index 0000000..5b362d0
--- /dev/null
+++ b/config/nvim/lua/format.org
@@ -0,0 +1,25 @@
+#+title: Neovim Formatting Settings
+Turn on =clang-format= in C, CUDA, C++, C#, Java, JavaScript, and JSON.
+#+begin_src lua :tangle yes
+  vim.cmd([[
+      let g:clang_format#code_style = 'file'
+      autocmd FileType c ClangFormatAutoEnable
+      autocmd FileType cuda ClangFormatAutoEnable
+      autocmd FileType cpp ClangFormatAutoEnable
+      autocmd FileType cs ClangFormatAutoEnable
+      autocmd FileType java ClangFormatAutoEnable
+      autocmd FileType javascript ClangFormatAutoEnable
+      autocmd FileType json ClangFormatAutoEnable
+      let g:vimtex_view_method = 'skim'
+  ]])
+#+end_src
+
+Auto-format Rust on save.
+#+begin_src lua :tangle yes
+  vim.g.rustfmt_autosave = 1
+#+end_src
+
+Start making a table by placing a =|=.
+#+begin_src lua :tangle yes
+  vim.g.table_mode_corner = '|'
+#+end_src
diff --git a/config/nvim/lua/languageServers.org b/config/nvim/lua/languageServers.org
new file mode 100644
index 0000000..8861ace
--- /dev/null
+++ b/config/nvim/lua/languageServers.org
@@ -0,0 +1,92 @@
+#+title: Neovim Language Server Configuration
+* Keybindings
+Set keys for LSP auto-completion.
+#+begin_src lua :tangle yes
+  vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
+  vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
+  vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
+  vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
+
+  -- Use an on_attach function to only map the following keys
+  -- after the language server attaches to the current buffer
+  local on_attach = function(client, bufnr)
+    -- Enable completion triggered by <c-x><c-o>
+    vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
+
+    local bufopts = { noremap=true, silent=true, buffer=bufnr }
+    vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
+    vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
+    vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
+    vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
+    vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
+    vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
+    vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
+    vim.keymap.set('n', '<space>wl', function()
+      print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
+    end, bufopts)
+    vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
+    vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
+    vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
+    vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
+    vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
+  end
+#+end_src
+
+* Languages
+Turn on LSP for various languages.
+#+begin_src lua :tangle yes
+  require('lspconfig')['awk_ls'].setup{
+      on_attach = on_attach,
+      flags = lsp_flags,
+  }
+
+  require('lspconfig')['bashls'].setup{
+      on_attach = on_attach,
+      flags = lsp_flags,
+  }
+
+  require('lspconfig')['fortls'].setup{
+      on_attach = on_attach,
+      flags = lsp_flags,
+  }
+
+  require('lspconfig')['hls'].setup{
+      on_attach = on_attach,
+      flags = lsp_flags
+  }
+
+  require('lspconfig')['pyright'].setup{
+      on_attach = on_attach,
+      flags = lsp_flags,
+  }
+
+  require('lspconfig')['tsserver'].setup{
+      on_attach = on_attach,
+      flags = lsp_flags,
+  }
+
+  require('lspconfig')['rust_analyzer'].setup{
+      on_attach = on_attach,
+      flags = lsp_flags,
+      settings = {
+        ["rust-analyzer"] = {}
+      }
+  }
+
+  require('lspconfig')['gopls'].setup{
+      on_attach = on_attach,
+      flags = lsp_flags
+  }
+
+  require('lspconfig')['clangd'].setup{
+      on_attach = on_attach,
+      flags = lsp_flags
+  }
+
+  require('lspconfig')['texlab'].setup{
+      on_attach = on_attach,
+      flags = lsp_flags
+  }
+
+  require('lspconfig')['perlpls'].setup{}
+#+end_src
diff --git a/config/nvim/lua/plugins.org b/config/nvim/lua/plugins.org
new file mode 100644
index 0000000..0dab41b
--- /dev/null
+++ b/config/nvim/lua/plugins.org
@@ -0,0 +1,49 @@
+#+title: Neovim Plugins
+* Setup
+Use =lazy= to manage plugins.
+#+begin_src lua :tangle yes
+  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)
+#+end_src
+
+* Plugins
+Install plugins here.
+#+begin_src lua :tangle yes
+require('lazy').setup({
+  'itchyny/lightline.vim',
+  'ayu-theme/ayu-vim',
+  'Raimondi/delimitMate',
+  'bronson/vim-trailing-whitespace',
+  'dhruvasagar/vim-table-mode',
+  'rhysd/vim-clang-format',
+  'chrisbra/csv.vim',
+  'neovim/nvim-lspconfig',
+  {
+      'nvim-treesitter/nvim-treesitter',
+      cmd = 'TSUpdate'
+  },
+  'junegunn/fzf',
+  'junegunn/fzf.vim',
+  'hrsh7th/nvim-cmp',
+  'hrsh7th/cmp-nvim-lsp',
+  'saadparwaiz1/cmp_luasnip',
+  'L3MON4D3/LuaSnip',
+  {
+      'fatih/vim-go',
+      cmd = 'GoUpdateBinaries',
+  },
+  'rust-lang/rust.vim',
+  'neovimhaskell/haskell-vim',
+  'lervag/vimtex',
+})
+#+end_src
-- 
cgit v1.2.3