From 869dcb7d72d2bd8c614dc378010b635d91d26242 Mon Sep 17 00:00:00 2001 From: Huck Boles Date: Sat, 15 Apr 2023 20:38:21 -0500 Subject: [PATCH] initial lua config --- init.lua | 39 +++++++++++++++ lua/function.lua | 0 lua/map.lua | 70 ++++++++++++++++++++++++++ lua/plugins.lua | 23 +++++++++ lua/plugins/cmp.lua | 36 ++++++++++++++ lua/plugins/lsp.lua | 69 ++++++++++++++++++++++++++ lua/plugins/lualine.lua | 64 ++++++++++++++++++++++++ lua/settings.lua | 80 ++++++++++++++++++++++++++++++ lua/theme.lua | 106 ++++++++++++++++++++++++++++++++++++++++ 9 files changed, 487 insertions(+) create mode 100644 init.lua create mode 100644 lua/function.lua create mode 100644 lua/map.lua create mode 100644 lua/plugins.lua create mode 100644 lua/plugins/cmp.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/lualine.lua create mode 100644 lua/settings.lua create mode 100644 lua/theme.lua diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..7aa51f3 --- /dev/null +++ b/init.lua @@ -0,0 +1,39 @@ +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", + "--single-branch", + "https://github.com/folke/lazy.nvim.git", + lazypath, + }) +end + +vim.opt.runtimepath:prepend(lazypath) + +require("lazy").setup("plugins", { + defaults = { lazy = true }, + install = { colorscheme = { "tokyonight" } }, + checker = { enabled = true }, + change_detection = { notify = false, }, + performance = { + rtp = { + disabled_plugins = { + "gzip", + "matchit", + "matchparen", + "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}) + +require('settings') +require('map') +require('theme') diff --git a/lua/function.lua b/lua/function.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/map.lua b/lua/map.lua new file mode 100644 index 0000000..ef00fe7 --- /dev/null +++ b/lua/map.lua @@ -0,0 +1,70 @@ +-- quick creation for splits, tabs, buffers +vim.keymap.set( 'n', 'h', ":vsplit " ) +vim.keymap.set( 'n', 'v', ":split " ) +vim.keymap.set( 'n', 't', ':tabnew ' ) +vim.keymap.set( 'n', 'B', 'bnext' ) + +-- fzf bindings +vim.keymap.set( 'n', 'H', "call fzf#run({ 'sink': 'vertical botright split' })" ) +vim.keymap.set( 'n', 'V', "call fzf#run({ 'sink': 'botright split' })" ) +vim.keymap.set( 'n', 'T', "call fzf#run({ 'sink': 'tabnew' })" ) +vim.keymap.set( 'n', 'f', 'GFiles' ) +vim.keymap.set( 'n', 'F', 'Files' ) +vim.keymap.set( 'n', 'b', 'Buffers' ) +vim.keymap.set( 'n', 'r', 'History:' ) + +-- move through virtual lines +vim.keymap.set( 'n', 'j', 'gj' ) +vim.keymap.set( 'n', 'k', 'gk' ) + +-- quick redo last macro +vim.keymap.set( 'n', 'Q', '@@' ) + +-- center the screen for movement commands +vim.keymap.set( 'n', '', 'za' ) +vim.keymap.set( 'n', 'n', 'nzz' ) +vim.keymap.set( 'n', 'N', 'Nzz' ) +vim.keymap.set( 'n', '', 'zz' ) +vim.keymap.set( 'n', '', 'zz' ) +vim.keymap.set( 'n', '', 'zz' ) +vim.keymap.set( 'n', '', 'zz' ) + +-- normal mode line splitting and joining +vim.keymap.set( 'n', 'H', 'izzO' ) +vim.keymap.set( 'n', 'L', 'izzi' ) +vim.keymap.set( 'n', 'K', 'Jx' ) + +-- toggle ui elements +vim.keymap.set( 'n', '_', 'nohlsearch' ) +vim.keymap.set( 'n', 'u', 'UndotreeToggle' ) +vim.keymap.set( 'n', '', 'ToggleTerm' ) + +-- editing and reloading init.lua +vim.keymap.set( 'n', '=', 'tabnew ~/.config/nvim/init.lua' ) +vim.keymap.set( 'n', 'q', +function() + vim.cmd('write') + vim.cmd('source ~/.config/nvim/init.lua') +end ) + +vim.keymap.set( 'n', 'Q', +function() + vim.cmd('write') + vim.cmd('source ~/.config/nvim/init.lua') + vim.cmd('PlugUpdate') +end ) + +-- autosave +vim.keymap.set( 'i', '', 'update' ) + +-- better terminal movement keys +vim.keymap.set('t', '', [[]], opts) +vim.keymap.set('t', '', [[]], opts) + +-- lsp diagnostic navigation +vim.keymap.set('n', 'n', vim.diagnostic.goto_next, opts) +vim.keymap.set('n', 'p', vim.diagnostic.goto_prev, opts) +vim.keymap.set('n', 'l', vim.diagnostic.open_float, opts) +-- vim.keymap.set('n', "L", require("lsp_lines").toggle) +vim.keymap.set('n', 'R', vim.lsp.buf.rename, opts) +vim.keymap.set('n', 'k', vim.lsp.buf.hover) diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..38ac366 --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,23 @@ +return { + 'tpope/vim-surround', + 'tpope/vim-obsession', + 'tpope/vim-endwise', + 'tpope/vim-repeat', + 'tpope/vim-commentary', + 'junegunn/fzf', + 'junegunn/fzf.vim', + + 'lukas-reineke/indent-blankline.nvim', + 'christoomey/vim-tmux-navigator', + 'norcalli/nvim-colorizer.lua', + 'Maan2003/lsp_lines.nvim', + 'mbbill/undotree', + + { + 'akinsho/toggleterm.nvim', + opts = { + shade_terminals = false, + size = 10 + } + } +} diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua new file mode 100644 index 0000000..67d105c --- /dev/null +++ b/lua/plugins/cmp.lua @@ -0,0 +1,36 @@ +return { + { + 'hrsh7th/nvim-cmp', + dependencies = { + 'onsails/lspkind.nvim', + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', + }, + opts = function() + local cmp = require('cmp') + return { + view = { entries = {name = 'custom', selection_order = 'near_cursor'} }, + formatting = { format= require('lspkind').cmp_format({ mode = 'symbol_text' }), }, + mapping = require('nvim-cmp').mapping.preset.insert({ + [''] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), + [''] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true, }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'path' }, + { name = 'buffer' } + }), + cmdline(':', { + view = { entries = {name = 'wildmenu', separator = '|'} }, + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } }) + }) + } + end + }, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..38a27e5 --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,69 @@ +return { + { + 'neovim/nvim-lspconfig', + dependencies = { + "mason.nvim", + "nvim-cmp", + "williamboman/mason-lspconfig.nvim", + }, + opts = { + diagnostics = { + virtual_text = false, + virtual_lines = true, + signs = false, + underline = true, + update_in_insert = false, + severity_sort = true, + } + }, + setup = {} + }, + + { + 'nvim-treesitter/nvim-treesitter', + opts = { + ensure_installed = { + "c", + "bash", + "comment", + "html", + "json", + "markdown", + "rust", + "regex", + "ruby" + }, + sync_install = true, + auto_install = true, + highlight = { enable = true, additional_vim_regex_highlighting = true, }, + indent = { enable = false }, + } + }, + + { + "williamboman/mason.nvim", + cmd = "Mason", + opts = { + ensure_installed = { + "stylua", + "shfmt", + }, + }, + }, + + { + "jose-elias-alvarez/null-ls.nvim", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { "mason.nvim" }, + opts = function() + local nls = require("null-ls") + return { + root_dir = require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git"), + sources = { + nls.builtins.formatting.stylua, + nls.builtins.formatting.shfmt, + }, + } + end + }, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..58ab03b --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,64 @@ +return { + 'nvim-lualine/lualine.nvim', + lazy = false, + opts = { + options = { + icons_enabled = true, + theme = 'auto', + component_separators = { left = '|', right = '|'}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {{'filename', path = 3}}, + lualine_c = {'git', 'branch', 'diff'}, + lualine_x = {'encoding'}, + lualine_y = {'diagnostics'}, + lualine_z = {'location', 'progress'} + }, + inactive_sections = { + lualine_a = {'filename'}, + lualine_b = {{'filename', path = 3}}, + lualine_c = {}, + lualine_x = {}, + lualine_y = {}, + lualine_z = {'location'} + }, + winbar = { + lualine_a = {'filename', 'filesize', 'filetype'}, + lualine_b = {}, + lualine_c = {}, + lualine_x = {}, + lualine_y = {}, + lualine_z = { + {'tabs', + tabs_color = { + active = 'StatusLine', + inactive = 'StatusLineNC', + }, + } + } + }, + inactive_winbar = { + lualine_a = {'filename'}, + lualine_b = {}, + lualine_c = {}, + lualine_x = {}, + lualine_y = {}, + lualine_z = {'ObsessionStatus'} + }, + extensions = {} + } +} diff --git a/lua/settings.lua b/lua/settings.lua new file mode 100644 index 0000000..c47ff86 --- /dev/null +++ b/lua/settings.lua @@ -0,0 +1,80 @@ +vim.g.c_syntax_for_h = 1 +vim.g.termdebug_wide = 1 + +vim.g.netrw_banner = 0 +vim.g.netrw_browse_split = 4 +vim.g.netrw_winsize = 20 +vim.g.netrw_liststyle = 4 + +vim.o.mousefocus = true +vim.o.mousemodel= 'extend' + +vim.o.lazyredraw = true + +vim.o.number = true +vim.o.relativenumber = true + +vim.o.linebreak = true +vim.o.breakindent = true +vim.o.showbreak = '> ' + +vim.o.ignorecase = true +vim.o.infercase = true +vim.o.smartcase = true +vim.o.incsearch = true +vim.o.hlsearch = true +vim.o.history = 10000 +vim.o.showmatch = true + +vim.o.autochdir = true +vim.o.browsedir = 'buffer' +vim.o.cdhome = true + +vim.o.wrapscan = true +vim.o.wildmenu = true +-- vim.o.wildignore = { '*.docx','*.jpg','*.png','*.pdf','*.pyc','*.exe','*.flv','*.img','*.xlsx' } + +vim.o.tabstop = 4 +vim.o.shiftwidth = 4 +vim.o.autoindent = true +vim.o.expandtab = true +vim.o.shiftround = true + +vim.o.showcmd = true +vim.o.cmdheight = 1 +vim.o.cmdwinheight = 10 + +vim.o.backupdir = '/home/huck/.local/state/nvim/backup' +vim.o.undodir = '/home/huck/.local/state/nvim/undo' + +vim.o.backup = true +vim.o.undofile = true +vim.o.swapfile = false +vim.o.undolevels = 2000 +vim.o.undoreload = 2000 + +vim.o.autoread = true + +vim.o.foldenable = true +vim.o.foldlevelstart = 5 +vim.o.foldmethod = 'indent' +-- vim.o.foldmarker = { '-v-','-^-' } +-- vim.o.backspace = { 'indent','eol','start' } + +vim.o.ttimeout = true +vim.o.ttimeoutlen = 1 +vim.o.confirm = true + +vim.o.splitright = true +vim.o.splitbelow = true + +vim.o.showtabline = 0 +vim.o.termguicolors = true +-- vim.o.completeopt = { 'menu', 'menuone', 'noselect' } + +vim.o.pumblend = 30 +vim.o.pumwidth = 50 + +vim.o.jumpoptions = 'stack' +vim.o.so = 10 + diff --git a/lua/theme.lua b/lua/theme.lua new file mode 100644 index 0000000..daa295a --- /dev/null +++ b/lua/theme.lua @@ -0,0 +1,106 @@ +vim.cmd([[ + +let backg = "#151515" +let foreg = "#d7d0c7" +let black = "#101010" +let grey = "#404040" +let red = "#e84f4f" +let redb = "#d23d3d" +let green = "#b8d68c" +let greenb = "#a0cf5d" +let yellow = "#e1aa5d" +let yellowb = "#f39d21" +let blue = "#7dc1cf" +let blueb = "#4e9fb1" +let magenta = "#9b64fb" +let magentab = "#8542ff" +let cyan = "#20a494" +let cyanb = "#21d6c7" +let white = "#909090" +let whiteb = "#dddddd" + +execute "highlight Normal guibg=" . backg +execute "highlight Normal guifg=" . foreg +execute "highlight comment guifg=" . white +execute "highlight LineNr guifg=" . yellow +execute "highlight CursorLineNr guifg=" . red +execute "highlight MatchParen guibg=" . grey +execute "highlight Constant guifg=" . magenta +execute "highlight Identifier guifg=" . blue +execute "highlight Statement guifg=" . greenb +execute "highlight Type guifg=" . blueb +execute "highlight PreProc guifg=" . yellowb +execute "highlight Title guifg=" . greenb +execute "highlight Question guifg=" . green +execute "highlight WildMenu guibg=" . yellow +execute "highlight WildMenu guibg=" . backg +execute "highlight SpecialKey guifg=" . cyan +execute "highlight NonText guifg=" . cyan +execute "highlight Directory guifg=" . blueb +execute "highlight ToolBarLine guibg=" . grey +execute "highlight ToolBarLine guifg=" . foreg +execute "highlight Error guibg=" . redb +execute "highlight Error guifg=" . foreg +execute "highlight Todo guibg=" . yellow +execute "highlight Todo guifg=" . backg +execute "highlight ErrorMsg guibg=" . redb +execute "highlight ErrorMsg guifg=" . foreg +execute "highlight Search guibg=" . green +execute "highlight Search guifg=" . backg +execute "highlight WarningMsg guifg=" . redb +execute "highlight Visual guibg=" . grey +execute "highlight Visual guifg=" . foreg +execute "highlight DiffAdd guibg=" . greenb +execute "highlight DiffAdd guifg=" . backg +execute "highlight DiffText guibg=" . cyan +execute "highlight DiffText guifg=" . foreg +execute "highlight DiffDelete guibg=" . grey +execute "highlight DiffDelete guifg=" . redb +execute "highlight DiffChange guibg=" . magenta +execute "highlight DiffChange guifg=" . foreg +execute "highlight Folded guibg=" . grey +execute "highlight Folded guifg=" . blueb +execute "highlight FoldColumn guibg=" . grey +execute "highlight FoldColumn guifg=" . blueb +execute "highlight Pmenu guifg=" . foreg +execute "highlight Pmenu guibg=" . grey +execute "highlight PmenuSel guibg=" . grey +execute "highlight PmenuSel guifg=" . green +execute "highlight VertSplit guibg=" . backg +execute "highlight VertSplit guifg=" . grey +execute "highlight StatusLineNC guibg=" . backg +execute "highlight StatuslineNC guifg=" . grey +execute "highlight StatusLine guibg=" . foreg +execute "highlight Statusline guifg=" . grey +execute "highlight NvimInternalError guifg=" . backg +execute "highlight TabLine guifg=" . backg +execute "highlight TabLine guibg=" . grey +execute "highlight TabLineFill guibg=" . backg +execute "highlight TabLineFill guifg=" . grey +execute "highlight TabLineSel gui= bold guifg=" . foreg +execute "highlight TabLineSel guibg=" . grey + +execute "highlight SignColumn guibg=" . grey +execute "highlight DiagnosticError guifg=" . redb +execute "highlight DiagnosticWarn guifg=" . yellowb +execute "highlight DiagnosticInfo guifg=" . blue +execute "highlight DiagnosticHint guifg=" . grey + +execute "highlight! CmpItemAbbrDeprecated guibg=NONE gui=strikethrough guifg=" . grey +execute "highlight! CmpItemAbbrMatch guibg=NONE guifg=" . blue +execute "highlight! CmpItemAbbrMatchFuzzy guibg=NONE guifg=" . blue +execute "highlight! CmpItemKindVariable guibg=NONE guifg=" . cyan +execute "highlight! CmpItemKindInterface guibg=NONE guifg=" . cyan +execute "highlight! CmpItemKindText guibg=NONE guifg=" . cyan +execute "highlight! CmpItemKindFunction guibg=NONE guifg=" . magenta +execute "highlight! CmpItemKindMethod guibg=NONE guifg=" . magenta +execute "highlight! CmpItemKindKeyword guibg=NONE guifg=" . foreg +execute "highlight! CmpItemKindProperty guibg=NONE guifg=" . foreg +execute "highlight! CmpItemKindUnit guibg=NONE guifg=" . foreg + + +execute "highlight IndentBlanklineChar guifg=" . grey +execute "highlight IndentBlanklineSpaceChar guifg=" . grey +execute "highlight IndentBlanklineSpaceCharBlankline guifg=" . grey +execute "highlight IndentBlanklineChar guifg=" . grey +]]) -- 2.44.2