]> git.huck.website - nvim.git/commitdiff
code formatting
authorHuck Boles <huck@huck.website>
Wed, 26 Apr 2023 16:34:43 +0000 (11:34 -0500)
committerHuck Boles <huck@huck.website>
Wed, 26 Apr 2023 16:34:43 +0000 (11:34 -0500)
lua/functions.lua
lua/map.lua
lua/plugins.lua
lua/plugins/cmp.lua
lua/plugins/lsp.lua
lua/plugins/lualine.lua
lua/plugins/telescope.lua
lua/plugins/treesitter.lua
lua/settings.lua
lua/theme.lua

index 7ab465fdc1f021af00c71fd45046012694b0768e..d0f2488917623acf2519b65bae159e0cc4f3399c 100644 (file)
@@ -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
+})
index cd33f4f13fab390bd486ee4d9bc64ebf0640e1b2..d11e9a8f790b7701c2e9ebe54780d686fa5d3f86 100644 (file)
@@ -1,47 +1,47 @@
 -- quick creation for splits, tabs, buffers
-vim.keymap.set( 'n', '<leader>h', ":vsplit " )
-vim.keymap.set( 'n', '<leader>v', ":split " )
-vim.keymap.set( 'n', '<leader>t', ':tabnew ' )
-vim.keymap.set( 'n', '<leader>b', '<CMD>bprev<CR>' )
+vim.keymap.set('n', '<leader>h', ":vsplit ")
+vim.keymap.set('n', '<leader>v', ":split ")
+vim.keymap.set('n', '<leader>t', ':tabnew ')
+vim.keymap.set('n', '<leader>b', '<CMD>bprev<CR>')
 
 -- 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', '<space>', 'za' )
-vim.keymap.set( 'n', 'n', 'nzz' )
-vim.keymap.set( 'n', 'N', 'Nzz' )
-vim.keymap.set( 'n', '<C-f>', '<C-f>zz' )
-vim.keymap.set( 'n', '<C-b>', '<C-b>zz' )
-vim.keymap.set( 'n', '<C-o>', '<C-o>zz' )
-vim.keymap.set( 'n', '<C-i>', '<C-i>zz' )
+vim.keymap.set('n', '<space>', 'za')
+vim.keymap.set('n', 'n', 'nzz')
+vim.keymap.set('n', 'N', 'Nzz')
+vim.keymap.set('n', '<C-f>', '<C-f>zz')
+vim.keymap.set('n', '<C-b>', '<C-b>zz')
+vim.keymap.set('n', '<C-o>', '<C-o>zz')
+vim.keymap.set('n', '<C-i>', '<C-i>zz')
 
 -- normal mode line splitting and joining
-vim.keymap.set( 'n', 'H', 'i<CR><ESC>zzO' )
-vim.keymap.set( 'n', 'L', 'i<CR><ESC>zzi' )
-vim.keymap.set( 'n', 'K', 'Jx' )
+vim.keymap.set('n', 'H', 'i<CR><ESC>zzO')
+vim.keymap.set('n', 'L', 'i<CR><ESC>zzi')
+vim.keymap.set('n', 'K', 'Jx')
 
 -- toggle ui elements
-vim.keymap.set( 'n', '_', '<CMD>nohlsearch<CR>' )
+vim.keymap.set('n', '_', '<CMD>nohlsearch<CR>')
 
 -- quick plugin editing
-vim.keymap.set( 'n', '<leader>=', '<CMD>tabnew ~/.config/nvim/init.lua<CR>' )
-vim.keymap.set( 'n', '<leader>q', '<CMD>Lazy<CR>' )
+vim.keymap.set('n', '<leader>=', '<CMD>tabnew ~/.config/nvim/init.lua<CR>')
+vim.keymap.set('n', '<leader>q', '<CMD>Lazy<CR>')
 
 -- better terminal movement keys
-vim.keymap.set('t', '<ESC>', [[<C-\><C-n>]] )
-vim.keymap.set('t', '<C-w>', [[<C-\><C-n><C-w>]] )
+vim.keymap.set('t', '<ESC>', [[<C-\><C-n>]])
+vim.keymap.set('t', '<C-w>', [[<C-\><C-n><C-w>]])
 
 -- lsp diagnostic navigation
-vim.keymap.set('n', '<leader>n', vim.diagnostic.goto_next )
-vim.keymap.set('n', '<leader>p', vim.diagnostic.goto_prev )
-vim.keymap.set('n', '<leader>R', vim.lsp.buf.rename )
-vim.keymap.set('n', '<leader>k', vim.lsp.buf.hover )
-vim.keymap.set('n', '<leader>K', vim.diagnostic.open_float )
+vim.keymap.set('n', '<leader>n', vim.diagnostic.goto_next)
+vim.keymap.set('n', '<leader>p', vim.diagnostic.goto_prev)
+vim.keymap.set('n', '<leader>R', vim.lsp.buf.rename)
+vim.keymap.set('n', '<leader>k', vim.lsp.buf.hover)
+vim.keymap.set('n', '<leader>K', vim.diagnostic.open_float)
 vim.keymap.set('n', '<leader>d',
     function()
         if vim.g.visible_diagnostics then
index fea28b9dbfff74f864d6d64655237859a5f6b2ea..014ec5e9fb265cd5a1b188b824738aad874292fd 100644 (file)
@@ -2,17 +2,16 @@ return {
 
     {
         'mbbill/undotree',
-        keys = { { '<leader>u', '<CMD>UndotreeToggle<CR>'} }
+        keys = { { '<leader>u', '<CMD>UndotreeToggle<CR>' } }
     },
 
-    { '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' },
 
     {
index 5841a8ab833c09ed4491ed3ecd49bdf035020298..15a5cc20acebad5300b502c0675eb3fa5f0304db 100644 (file)
@@ -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({
-                        ['<C-b>'] = cmp.mapping.scroll_docs(-4),
-                        ['<C-f>'] = cmp.mapping.scroll_docs(4),
-                        ['<TAB>'] = cmp.mapping.complete(),
-                        ['<C-c>'] = cmp.mapping.abort(),
-                        ['<TAB>'] = 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({
+                    ['<C-b>'] = cmp.mapping.scroll_docs(-4),
+                    ['<C-f>'] = cmp.mapping.scroll_docs(4),
+                    ['<TAB>'] = cmp.mapping.complete(),
+                    ['<C-c>'] = cmp.mapping.abort(),
+                    ['<TAB>'] = 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
     },
 }
index e6bc3bfbf0f66023d16e3b1d610b2eddee6b0996..6b1ff580e9f2b27997a34fd4be57e44ecc366a06 100644 (file)
@@ -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
+    },
+
 }
index 58ab03b2aa00ece71f7414f6feec9e7fd0d6d4f5..7b29d9f50f453536c21598bd3959e5013d53137c 100644 (file)
@@ -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 = {}
     }
index 92f6d741d0b6f3038d93d4b3fe895abd473b665e..5daa76018ca24c4d25a8cac0a5e04cbf619582c1 100644 (file)
@@ -3,13 +3,13 @@ return {
         'nvim-telescope/telescope.nvim',
         dependencies = { 'nvim-lua/plenary.nvim' },
         keys = {
-            { '<leader>f', '<CMD>Telescope git_files<CR>' },
-            { '<leader>F', '<CMD>Telescope find_files<CR>' },
+            { '<leader>f',     '<CMD>Telescope git_files<CR>' },
+            { '<leader>F',     '<CMD>Telescope find_files<CR>' },
             { '<leader><C-f>', '<CMD>Telescope live_grep<CR>' },
-            { '<leader>B', '<CMD>Telescope buffers<CR>' },
+            { '<leader>B',     '<CMD>Telescope buffers<CR>' },
             { '<leader><C-r>', '<CMD>Telescope command_history<CR>' },
-            { '<leader>D', '<CMD>Telescope diagnostics<CR>' },
-            { '<leader>g', '<CMD>Telescope git_commits<CR>' },
+            { '<leader>D',     '<CMD>Telescope diagnostics<CR>' },
+            { '<leader>g',     '<CMD>Telescope git_commits<CR>' },
         },
         config = function()
             require('telescope').setup {
index 0c7ff6f0bcb25eb4b31778ebf6091cd7852d9bf2..b87674f529e4e47d52b145adabf0cf9db96d08a6 100644 (file)
@@ -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()
index 8194ee0ddb084bfafde840598b320c581aa59a77..d4f2d7c5a8356573c2ddfcd8746e1237cdbf0b44 100644 (file)
@@ -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
-
index 69cd227f64279a030648b4b2e35c6547d20caa2d..d4b63171cf6b14b805ff49b1bff029414577f73c 100644 (file)
@@ -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)
-