]> git.huck.website - nvim.git/commitdiff
file type templating
authorHuck Boles <huck@huck.website>
Tue, 25 Apr 2023 16:33:43 +0000 (11:33 -0500)
committerHuck Boles <huck@huck.website>
Tue, 25 Apr 2023 16:33:43 +0000 (11:33 -0500)
lua/functions.lua
lua/map.lua
lua/plugins.lua
lua/plugins/lsp.lua
lua/theme.lua

index e7bb86f895c65bb07483c802d65fb4e45b3e82ee..f6e81c930b2c8c4478f944b3cc1328f871ce40f9 100644 (file)
@@ -1,6 +1,32 @@
+-- open help windows in a vertical split
 vim.api.nvim_create_autocmd("BufWinEnter", {
     pattern = { "*.txt" },
-    callback = function() 
+    callback = function()
         if vim.o.filetype == 'help' then vim.cmd.wincmd("L") end
     end
 })
+
+-- check template folder and if a template.[filetype] exists use it
+vim.api.nvim_create_autocmd("BufNewFile", {
+    pattern = { "*" },
+    callback = function()
+        local ext = vim.fn.expand('%:e')
+        local filename = vim.fn.expand('%:t')
+        local dir = '/home/huck/repos/templates/'
+
+        local copy = function(name)
+            local path = dir .. name .. ext
+            print(path)
+            print(ext)
+            if vim.fn.filereadable(path) == 1 then
+                vim.cmd('0r ' .. path)
+            end
+        end
+
+        if ext ~= '' then
+            copy('template.')
+        elseif filename == 'Makefile' or 'LICENSE' then
+            copy(filename)
+        end
+    end
+})
index bb0c4f51073bed951ea60e0f9e8fdbd3ea9cc8ca..cd33f4f13fab390bd486ee4d9bc64ebf0640e1b2 100644 (file)
@@ -2,7 +2,7 @@
 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>bnext<CR>' )
+vim.keymap.set( 'n', '<leader>b', '<CMD>bprev<CR>' )
 
 -- move through virtual lines
 vim.keymap.set( 'n', 'j', 'gj' )
@@ -51,5 +51,5 @@ vim.keymap.set('n', '<leader>d',
             vim.diagnostic.enable()
             vim.g.visible_diagnostics = true
         end
-    end,
-opts)
+    end
+)
index 8523e051bfde827bea551cba7457326deb08caa8..fea28b9dbfff74f864d6d64655237859a5f6b2ea 100644 (file)
@@ -27,11 +27,12 @@ return {
     {
         'folke/trouble.nvim',
         keys = {
-            { '<leader>l', '<CMD>TroubleToggle<CR>' },
+            { '<leader>l', '<CMD>TroubleToggle document_diagnostics<CR>' },
+            { '<leader>L', '<CMD>TroubleToggle workspace_diagnostics<CR>' },
+            { '<leader>r', '<CMD>TroubleToggle lsp_references<CR>' },
         },
         opts = {
             icons = false,
-            mode = 'workspace_diagnostics',
             use_diagnostic_signs = true
         }
     }
index bab7137f958000d5041a35611cbada1702a8b288..e6bc3bfbf0f66023d16e3b1d610b2eddee6b0996 100644 (file)
@@ -10,15 +10,6 @@ return {
             'williamboman/mason-lspconfig',
         },
         config = function()
-            vim.lsp.diagnostics = {
-                virtual_text = false,
-                virtual_lines = true,
-                signs = true,
-                underline = true,
-                update_in_insert = false,
-                severity_sort = true,
-            }
-
             local lspconfig = require('lspconfig')
             require('mason').setup()
 
@@ -34,17 +25,30 @@ return {
             })
 
             local border = {
-                {"â\94\8c", "FloatBorder"},
-                {"â\94\80", "FloatBorder"},
-                {"â\94\90", "FloatBorder"},
-                {"â\94\82", "FloatBorder"},
-                {"â\94\98", "FloatBorder"},
-                {"â\94\80", "FloatBorder"},
-                {"â\94\94", "FloatBorder"},
-                {"â\94\82", "FloatBorder"},
+                {"â\94\8f", "FloatBorder"},
+                {"â\94\81", "FloatBorder"},
+                {"â\94\93", "FloatBorder"},
+                {"â\94\83", "FloatBorder"},
+                {"â\94\9b", "FloatBorder"},
+                {"â\94\81", "FloatBorder"},
+                {"â\94\97", "FloatBorder"},
+                {"â\94\83", "FloatBorder"},
             }
 
-            -- To instead override globally
+            local signs = { Error = ">>", Warn = "> ", Hint = "- ", Info = "  " }
+
+            vim.lsp.diagnostics = {
+                signs = true,
+                underline = true,
+                update_in_insert = false,
+                severity_sort = { reverse = true },
+            }
+
+            for type, icon in pairs(signs) do
+                local hl = "DiagnosticSign" .. type
+                vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
+            end
+
             local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
             function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
                 opts = opts or {}
index e2a3b11d69eaf0237fe52d70117a3cdc711d60ee..69cd227f64279a030648b4b2e35c6547d20caa2d 100644 (file)
@@ -95,7 +95,7 @@ highlight("FoldColumn", blue, dark_grey, c_blue, c_grey, nil, nil)
 -- UI
 highlight("WildMenu", grey, black, c_grey, c_black, nil, nil)
 highlight("Title", green, black, c_green, c_black, bold, nil)
-highlight("ToolBarLine", black, dark_grey, c_black, c_grey, nil, nil)
+highlight("ToolBarLine", dark_grey, black, c_grey, c_black, nil, nil)
 highlight("Pmenu", white, black, nil, c_black, nil, nil)
 highlight("PmenuSbar", white, black, nil, c_black, nil, nil)
 highlight("PmenuThumb", grey, black, nil, c_black, nil, nil)