From 6c0af6501973302e75cfce0e8320ddf7410ed3c6 Mon Sep 17 00:00:00 2001 From: Huck Boles Date: Wed, 26 Apr 2023 11:34:43 -0500 Subject: [PATCH] code formatting --- lua/functions.lua | 8 +++ lua/map.lua | 54 ++++++++--------- lua/plugins.lua | 15 +++-- lua/plugins/cmp.lua | 70 +++++++++++---------- lua/plugins/lsp.lua | 36 ++++++++--- lua/plugins/lualine.lua | 41 +++++++------ lua/plugins/telescope.lua | 10 +-- lua/plugins/treesitter.lua | 2 +- lua/settings.lua | 3 +- lua/theme.lua | 121 ++++++++++++++++++------------------- 10 files changed, 194 insertions(+), 166 deletions(-) diff --git a/lua/functions.lua b/lua/functions.lua index 7ab465f..d0f2488 100644 --- a/lua/functions.lua +++ b/lua/functions.lua @@ -28,3 +28,11 @@ vim.api.nvim_create_autocmd("BufNewFile", { end end }) + +-- auto format code on save +vim.api.nvim_create_autocmd('BufWritePre', { + pattern = { "*" }, + callback = function() + vim.lsp.buf.format() + end +}) diff --git a/lua/map.lua b/lua/map.lua index cd33f4f..d11e9a8 100644 --- a/lua/map.lua +++ b/lua/map.lua @@ -1,47 +1,47 @@ -- 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', 'bprev' ) +vim.keymap.set('n', 'h', ":vsplit ") +vim.keymap.set('n', 'v', ":split ") +vim.keymap.set('n', 't', ':tabnew ') +vim.keymap.set('n', 'b', 'bprev') -- move through virtual lines -vim.keymap.set( 'n', 'j', 'gj' ) -vim.keymap.set( 'n', 'k', 'gk' ) +vim.keymap.set('n', 'j', 'gj') +vim.keymap.set('n', 'k', 'gk') -- quick redo last macro -vim.keymap.set( 'n', 'Q', '@@' ) +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' ) +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' ) +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', '_', 'nohlsearch') -- quick plugin editing -vim.keymap.set( 'n', '=', 'tabnew ~/.config/nvim/init.lua' ) -vim.keymap.set( 'n', 'q', 'Lazy' ) +vim.keymap.set('n', '=', 'tabnew ~/.config/nvim/init.lua') +vim.keymap.set('n', 'q', 'Lazy') -- better terminal movement keys -vim.keymap.set('t', '', [[]] ) -vim.keymap.set('t', '', [[]] ) +vim.keymap.set('t', '', [[]]) +vim.keymap.set('t', '', [[]]) -- lsp diagnostic navigation -vim.keymap.set('n', 'n', vim.diagnostic.goto_next ) -vim.keymap.set('n', 'p', vim.diagnostic.goto_prev ) -vim.keymap.set('n', 'R', vim.lsp.buf.rename ) -vim.keymap.set('n', 'k', vim.lsp.buf.hover ) -vim.keymap.set('n', 'K', vim.diagnostic.open_float ) +vim.keymap.set('n', 'n', vim.diagnostic.goto_next) +vim.keymap.set('n', 'p', vim.diagnostic.goto_prev) +vim.keymap.set('n', 'R', vim.lsp.buf.rename) +vim.keymap.set('n', 'k', vim.lsp.buf.hover) +vim.keymap.set('n', 'K', vim.diagnostic.open_float) vim.keymap.set('n', 'd', function() if vim.g.visible_diagnostics then diff --git a/lua/plugins.lua b/lua/plugins.lua index fea28b9..014ec5e 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -2,17 +2,16 @@ return { { 'mbbill/undotree', - keys = { { 'u', 'UndotreeToggle'} } + keys = { { 'u', 'UndotreeToggle' } } }, - { 'christoomey/vim-tmux-navigator', lazy = false }, - - { 'tpope/vim-obsession', lazy = false }, - { 'tpope/vim-repeat', event = "VeryLazy" }, - { 'tpope/vim-surround', event = "VeryLazy" }, - { 'tpope/vim-endwise', event = "VeryLazy" }, - { 'tpope/vim-commentary',event = "VeryLazy" }, + { 'christoomey/vim-tmux-navigator', lazy = false }, + { 'tpope/vim-obsession', lazy = false }, + { 'tpope/vim-repeat', event = "VeryLazy" }, + { 'tpope/vim-surround', event = "VeryLazy" }, + { 'tpope/vim-endwise', event = "VeryLazy" }, + { 'tpope/vim-commentary', event = "VeryLazy" }, { 'lukas-reineke/indent-blankline.nvim', event = 'VeryLazy' }, { diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 5841a8a..15a5cc2 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -12,49 +12,53 @@ return { 'hrsh7th/vim-vsnip', }, config = function() - local cmp = require'cmp' - cmp.setup({ - snippet = { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end, }, - formatting = { - format = require('lspkind').cmp_format({ mode = "text_symbol" }) - }, - window = { }, - 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 }), - }), - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'vsnip' }, - { name = 'buffer' }, - }) + local cmp = require 'cmp' + cmp.setup({ + snippet = { expand = function(args) vim.fn["vsnip#anonymous"](args.body) end, }, + formatting = { + format = require('lspkind').cmp_format({ mode = "text_symbol" }) + }, + window = {}, + 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 }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'vsnip' }, + { name = 'buffer' }, }) + }) - cmp.setup.cmdline({ '/', '?' }, { - view = { entries = { + cmp.setup.cmdline({ '/', '?' }, { + view = { + entries = { name = 'wildmenu', separator = '|', selection_order = 'near_cursor', - } }, - mapping = cmp.mapping.preset.cmdline(), - sources = { { name = 'buffer' } } - }) + } + }, + mapping = cmp.mapping.preset.cmdline(), + sources = { { name = 'buffer' } } + }) - cmp.setup.cmdline(':', { - view = { entries = { + cmp.setup.cmdline(':', { + view = { + entries = { name = 'wildmenu', separator = '|', selection_order = 'near_cursor', - } }, - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } }) - }) + } + }, + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ { name = 'path' } }, { { name = 'cmdline' } }) + }) - local capabilities = require('cmp_nvim_lsp').default_capabilities() - require('lspconfig')['rust_analyzer'].setup { capabilities = capabilities } + local capabilities = require('cmp_nvim_lsp').default_capabilities() + require('lspconfig')['rust_analyzer'].setup { capabilities = capabilities } end }, } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index e6bc3bf..6b1ff58 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -19,20 +19,20 @@ return { }) require('mason-lspconfig').setup_handlers({ - function (server_name) + function(server_name) lspconfig[server_name].setup({}) end }) local border = { - {"┏", "FloatBorder"}, - {"━", "FloatBorder"}, - {"┓", "FloatBorder"}, - {"┃", "FloatBorder"}, - {"┛", "FloatBorder"}, - {"━", "FloatBorder"}, - {"┗", "FloatBorder"}, - {"┃", "FloatBorder"}, + { "┏", "FloatBorder" }, + { "━", "FloatBorder" }, + { "┓", "FloatBorder" }, + { "┃", "FloatBorder" }, + { "┛", "FloatBorder" }, + { "━", "FloatBorder" }, + { "┗", "FloatBorder" }, + { "┃", "FloatBorder" }, } local signs = { Error = ">>", Warn = "> ", Hint = "- ", Info = " " } @@ -57,4 +57,22 @@ return { end end }, + + { + 'jay-babu/mason-null-ls.nvim', + event = { 'BufReadPre', 'BufNewFile' }, + dependencies = { + 'mason.nvim', + { + 'jose-elias-alvarez/null-ls.nvim', + dependencies = { 'plenary.nvim' }, + } + }, + config = function() + require('mason-null-ls').setup({ + automatic_setup = true, + }) + end + }, + } diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index 58ab03b..7b29d9f 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -5,45 +5,46 @@ return { options = { icons_enabled = true, theme = 'auto', - component_separators = { left = '|', right = '|'}, - section_separators = { left = '', right = ''}, + component_separators = { left = '|', right = '|' }, + section_separators = { left = '', right = '' }, disabled_filetypes = { - statusline = {}, - winbar = {}, + statusline = {}, + winbar = {}, }, ignore_focus = {}, always_divide_middle = true, globalstatus = false, refresh = { - statusline = 1000, - tabline = 1000, - winbar = 1000, + 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'} + 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_a = { 'filename' }, + lualine_b = { { 'filename', path = 3 } }, lualine_c = {}, lualine_x = {}, lualine_y = {}, - lualine_z = {'location'} + lualine_z = { 'location' } }, winbar = { - lualine_a = {'filename', 'filesize', 'filetype'}, + lualine_a = { 'filename', 'filesize', 'filetype' }, lualine_b = {}, lualine_c = {}, lualine_x = {}, lualine_y = {}, lualine_z = { - {'tabs', + { + 'tabs', tabs_color = { active = 'StatusLine', inactive = 'StatusLineNC', @@ -52,12 +53,12 @@ return { } }, inactive_winbar = { - lualine_a = {'filename'}, + lualine_a = { 'filename' }, lualine_b = {}, lualine_c = {}, lualine_x = {}, lualine_y = {}, - lualine_z = {'ObsessionStatus'} + lualine_z = { 'ObsessionStatus' } }, extensions = {} } diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 92f6d74..5daa760 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -3,13 +3,13 @@ return { 'nvim-telescope/telescope.nvim', dependencies = { 'nvim-lua/plenary.nvim' }, keys = { - { 'f', 'Telescope git_files' }, - { 'F', 'Telescope find_files' }, + { 'f', 'Telescope git_files' }, + { 'F', 'Telescope find_files' }, { '', 'Telescope live_grep' }, - { 'B', 'Telescope buffers' }, + { 'B', 'Telescope buffers' }, { '', 'Telescope command_history' }, - { 'D', 'Telescope diagnostics' }, - { 'g', 'Telescope git_commits' }, + { 'D', 'Telescope diagnostics' }, + { 'g', 'Telescope git_commits' }, }, config = function() require('telescope').setup { diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 0c7ff6f..b87674f 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -2,7 +2,7 @@ return { { 'nvim-treesitter/nvim-treesitter', build = function() - require('nvim-treesitter.install').update( { with_sync = true } ) + require('nvim-treesitter.install').update({ with_sync = true }) end, event = { 'BufReadPost', 'BufNewFile' }, config = function() diff --git a/lua/settings.lua b/lua/settings.lua index 8194ee0..d4f2d7c 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -14,7 +14,7 @@ vim.o.clipboard = 'unnamedplus,unnamed' vim.o.lazyredraw = true -vim.o.number = false +vim.o.number = false vim.o.signcolumn = 'yes' vim.o.linebreak = true @@ -74,4 +74,3 @@ vim.o.termguicolors = true vim.o.jumpoptions = 'stack' vim.o.so = 10 - diff --git a/lua/theme.lua b/lua/theme.lua index 69cd227..d4b6317 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -1,52 +1,52 @@ -vim.o.background = "dark" - -local black = "#151515" -local red = "#e84f4f" -local green = "#b8d68c" -local yellow = "#e1aa5d" -local blue = "#7dc1cf" -local purple = "#9b64fb" -local pink = "#6d878d" -local white = "#d7d0c7" - -local dark_grey = "#333333" -local grey = "#888888" -local light_grey = "#aaaaaa" - -local dark_red = "#d23d3d" -local dark_green = "#a0cf5d" -local dark_yellow = "#f39d21" -local dark_blue = "#4e9fb1" -local dark_purple = "#8542ff" -local dark_pink = "#42717b" -local dark_white = "#f7f0dd" - -local c_black = "0" -local c_red = "1" -local c_green = "2" -local c_yellow = "3" -local c_blue = "4" -local c_purple = "5" -local c_pink = "6" -local c_white = "7" -local c_grey = "8" -local c_dark_red = "9" -local c_dark_green = "10" -local c_dark_yellow = "11" -local c_dark_blue = "12" -local c_dark_purple = "13" -local c_dark_pink = "14" - -vim.g.terminal_color_0 = black -vim.g.terminal_color_1 = red -vim.g.terminal_color_2 = green -vim.g.terminal_color_3 = yellow -vim.g.terminal_color_4 = blue -vim.g.terminal_color_5 = purple -vim.g.terminal_color_6 = pink -vim.g.terminal_color_7 = white -vim.g.terminal_color_8 = grey -vim.g.terminal_color_9 = dark_red +vim.o.background = "dark" + +local black = "#151515" +local red = "#e84f4f" +local green = "#b8d68c" +local yellow = "#e1aa5d" +local blue = "#7dc1cf" +local purple = "#9b64fb" +local pink = "#6d878d" +local white = "#d7d0c7" + +local dark_grey = "#333333" +local grey = "#888888" +local light_grey = "#aaaaaa" + +local dark_red = "#d23d3d" +local dark_green = "#a0cf5d" +local dark_yellow = "#f39d21" +local dark_blue = "#4e9fb1" +local dark_purple = "#8542ff" +local dark_pink = "#42717b" +local dark_white = "#f7f0dd" + +local c_black = "0" +local c_red = "1" +local c_green = "2" +local c_yellow = "3" +local c_blue = "4" +local c_purple = "5" +local c_pink = "6" +local c_white = "7" +local c_grey = "8" +local c_dark_red = "9" +local c_dark_green = "10" +local c_dark_yellow = "11" +local c_dark_blue = "12" +local c_dark_purple = "13" +local c_dark_pink = "14" + +vim.g.terminal_color_0 = black +vim.g.terminal_color_1 = red +vim.g.terminal_color_2 = green +vim.g.terminal_color_3 = yellow +vim.g.terminal_color_4 = blue +vim.g.terminal_color_5 = purple +vim.g.terminal_color_6 = pink +vim.g.terminal_color_7 = white +vim.g.terminal_color_8 = grey +vim.g.terminal_color_9 = dark_red vim.g.terminal_color_10 = dark_green vim.g.terminal_color_11 = dark_yellow vim.g.terminal_color_12 = dark_blue @@ -54,22 +54,22 @@ vim.g.terminal_color_13 = dark_purple vim.g.terminal_color_14 = dark_pink vim.g.terminal_color_15 = dark_white -local bold = "bold" -local italic = "italic" -local underline = "underline" +local bold = "bold" +local italic = "italic" +local underline = "underline" local function highlight(group, guifg, guibg, ctermfg, ctermbg, attr, guisp) local parts = { group } - if guifg then table.insert(parts, "guifg="..guifg) end - if guibg then table.insert(parts, "guibg="..guibg) end - if ctermfg then table.insert(parts, "ctermfg="..ctermfg) end - if ctermbg then table.insert(parts, "ctermbg="..ctermbg) end + if guifg then table.insert(parts, "guifg=" .. guifg) end + if guibg then table.insert(parts, "guibg=" .. guibg) end + if ctermfg then table.insert(parts, "ctermfg=" .. ctermfg) end + if ctermbg then table.insert(parts, "ctermbg=" .. ctermbg) end if attr then - table.insert(parts, "gui="..attr) - table.insert(parts, "cterm="..attr) + table.insert(parts, "gui=" .. attr) + table.insert(parts, "cterm=" .. attr) end - if guisp then table.insert(parts, "guisp="..guisp) end - vim.api.nvim_command('highlight '..table.concat(parts, ' ')) + if guisp then table.insert(parts, "guisp=" .. guisp) end + vim.api.nvim_command('highlight ' .. table.concat(parts, ' ')) end -- highlight(group, guifg, guibg, ctermfg, ctermbg, attr, guisp) @@ -288,4 +288,3 @@ highlight("lualine_y_diagnostics_hint_inactive", grey, black, c_grey, c_black, n highlight("lualine_c_diff_added_inactive", green, black, c_green, c_black, nil, nil) highlight("lualine_c_diff_modified_inactive", yellow, black, c_yellow, c_black, nil, nil) highlight("lualine_c_diff_removed_inactive", blue, black, c_blue, c_black, nil, nil) - -- 2.44.2