From 20954190a8ef4e277af710f960c4663635188b91 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Sat, 2 Mar 2024 11:29:43 +0000 Subject: [PATCH] Initial experiments with Lua config --- .gitignore | 1 + init.lua | 31 +++++++++++++++++ lua/mappings.lua | 23 +++++++++++++ lua/plugins/colorscheme.lua | 11 +++++++ lua/plugins/completions.lua | 46 ++++++++++++++++++++++++++ lua/plugins/statusline.lua | 9 +++++ lua/plugins/treesitter.lua | 66 +++++++++++++++++++++++++++++++++++++ lua/settings.lua | 21 ++++++++++++ 8 files changed, 208 insertions(+) create mode 100644 .gitignore create mode 100644 init.lua create mode 100644 lua/mappings.lua create mode 100644 lua/plugins/colorscheme.lua create mode 100644 lua/plugins/completions.lua create mode 100644 lua/plugins/statusline.lua create mode 100644 lua/plugins/treesitter.lua create mode 100644 lua/settings.lua 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/init.lua b/init.lua new file mode 100644 index 0000000..189cc68 --- /dev/null +++ b/init.lua @@ -0,0 +1,31 @@ +require('settings') +require('mappings') + +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({ + import = 'plugins', + change_detection = { + enabled = false, + }, +}) +-- { +-- { 'nvim-telescope/telescope.nvim', dependencies = { 'nvim-lua/plenary.nvim' } }, +-- { 'neovim/nvim-lspconfig' }, +-- }) + +-- require('telescope').setup() +-- require('lspconfig').clangd.setup() +-- require('lspconfig').cmake.setup() +-- require('lspconfig').lua_ls.setup() diff --git a/lua/mappings.lua b/lua/mappings.lua new file mode 100644 index 0000000..c522303 --- /dev/null +++ b/lua/mappings.lua @@ -0,0 +1,23 @@ +vim.g.mapleader = ' ' + +-- Quick write +vim.keymap.set('n', 'w', ':w!', {noremap = true}) + +-- Treat long lines as line containing breaks +vim.keymap.set('n', 'j', 'gj', {noremap = true}) +vim.keymap.set('n', 'k', 'gk', {noremap = true}) + +vim.keymap.set('n', 'tn', ':tabnew', {noremap = true}) +vim.keymap.set('n', 'tc', ':tabclose', {noremap = true}) +vim.keymap.set('n', 'to', ':tabonly', {noremap = true}) +vim.keymap.set('n', 'tm', ':tabmove', {noremap = true}) + +-- Quickly access spelling menu +vim.keymap.set('i', '', 'us', {noremap = true}) +vim.keymap.set('n', '', 'ius', {noremap = true}) + +-- Clear search highlights +vim.keymap.set('n', '', ':nohlsearch', {noremap = true}) + +-- Disable 'Q' from opening Ex mode +vim.keymap.set('n', 'Q', '', {noremap = true}) diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..32f1c89 --- /dev/null +++ b/lua/plugins/colorscheme.lua @@ -0,0 +1,11 @@ +return { + 'rose-pine/neovim', name = 'rose-pine', + config = function() + require('rose-pine').setup({ + styles = { + transparency = true, + }, + }) + vim.cmd('colorscheme rose-pine') + end +} diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua new file mode 100644 index 0000000..bf756da --- /dev/null +++ b/lua/plugins/completions.lua @@ -0,0 +1,46 @@ +return { + 'neovim/nvim-lspconfig', + dependencies = { + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + + 'neovim/nvim-lspconfig', + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', + 'hrsh7th/nvim-cmp', + + 'folke/neodev.nvim', + + -- TODO: https://github.com/j-hui/fidget.nvim + -- TODO: https://github.com/nvimtools/none-ls.nvim + -- TODO: https://github.com/mfussenegger/nvim-dap + -- TODO: https://github.com/rcarriga/nvim-dap-ui + }, + config = function() + require('neodev').setup() + + require('mason').setup() + require('mason-lspconfig').setup({ + ensure_installed = { + 'clangd', + 'cmake', + 'lua_ls', + }, + automatic_installation = false, + handlers = { + function(server_name) + require('lspconfig')[server_name].setup({}) + end, + }, + }) + + require('cmp').setup({ + sources = { + { name = 'nvim_lsp' }, + -- TODO: snippets + }, + }) + end, +} diff --git a/lua/plugins/statusline.lua b/lua/plugins/statusline.lua new file mode 100644 index 0000000..ee22db9 --- /dev/null +++ b/lua/plugins/statusline.lua @@ -0,0 +1,9 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { + 'nvim-tree/nvim-web-devicons', + }, + -- config = function() + -- require('lualine').setup() + -- end +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..b75205a --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,66 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + require('nvim-treesitter').setup() + local configs = require("nvim-treesitter.configs") + configs.setup({ + ensure_installed = { + "asm", + "bash", + "c", + "cmake", + "cpp", + "css", + "csv", + "cuda", + "diff", + "disassembly", + "dockerfile", + "dot", + "doxygen", + "git_config", + "git_rebase", + "gitattributes", + "gitignore", + "glsl", + "gpg", + "hlsl", + "html", + "ini", + "javascript", + "jq", + "json", + "llvm", + "lua", + "make", + "meson", + "ninja", + "objc", + "objdump", + "printf", + "proto", + "python", + "query", + "regex", + "requirements", + "rst", + "ssh_config", + "strace", + "tmux", + "toml", + "vim", + "vimdoc", + "xml", + "yaml", + }, + sync_install = false, + highlight = { + enable = true, + }, + indent = { + enable = true, + }, + }) + end +} diff --git a/lua/settings.lua b/lua/settings.lua new file mode 100644 index 0000000..c4adbdc --- /dev/null +++ b/lua/settings.lua @@ -0,0 +1,21 @@ +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.signcolumn = 'yes' +vim.opt.sidescrolloff = 5 +vim.opt.list = true +vim.opt.listchars = 'nbsp:⦸,trail:·,tab:▹┄,extends:»,precedes:«' +vim.opt.wrap = true +vim.opt.linebreak = true +vim.opt.showbreak = '↳ ' +vim.opt.showmode = false +vim.opt.writebackup = false +vim.opt.hlsearch = true +vim.opt.incsearch = true +vim.opt.fileignorecase = false +vim.opt.hidden = true +vim.opt.splitbelow = true +vim.opt.splitright = true +vim.opt.switchbuf = 'usetab' +vim.opt.autowrite = true +vim.opt.joinspaces = false +vim.opt.mouse = 'a'