From: Huck Boles Date: Tue, 25 Apr 2023 16:33:43 +0000 (-0500) Subject: file type templating X-Git-Url: https://git.huck.website/?a=commitdiff_plain;h=851c8d792e20991f6f982cfdd741f38f48065f7c;p=nvim.git file type templating --- diff --git a/lua/functions.lua b/lua/functions.lua index e7bb86f..f6e81c9 100644 --- a/lua/functions.lua +++ b/lua/functions.lua @@ -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 +}) diff --git a/lua/map.lua b/lua/map.lua index bb0c4f5..cd33f4f 100644 --- a/lua/map.lua +++ b/lua/map.lua @@ -2,7 +2,7 @@ vim.keymap.set( 'n', 'h', ":vsplit " ) vim.keymap.set( 'n', 'v', ":split " ) vim.keymap.set( 'n', 't', ':tabnew ' ) -vim.keymap.set( 'n', 'b', 'bnext' ) +vim.keymap.set( 'n', 'b', 'bprev' ) -- move through virtual lines vim.keymap.set( 'n', 'j', 'gj' ) @@ -51,5 +51,5 @@ vim.keymap.set('n', 'd', vim.diagnostic.enable() vim.g.visible_diagnostics = true end - end, -opts) + end +) diff --git a/lua/plugins.lua b/lua/plugins.lua index 8523e05..fea28b9 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -27,11 +27,12 @@ return { { 'folke/trouble.nvim', keys = { - { 'l', 'TroubleToggle' }, + { 'l', 'TroubleToggle document_diagnostics' }, + { 'L', 'TroubleToggle workspace_diagnostics' }, + { 'r', 'TroubleToggle lsp_references' }, }, opts = { icons = false, - mode = 'workspace_diagnostics', use_diagnostic_signs = true } } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index bab7137..e6bc3bf 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -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 = { - {"┌", "FloatBorder"}, - {"─", "FloatBorder"}, - {"┐", "FloatBorder"}, - {"│", "FloatBorder"}, - {"┘", "FloatBorder"}, - {"─", "FloatBorder"}, - {"└", "FloatBorder"}, - {"│", "FloatBorder"}, + {"┏", "FloatBorder"}, + {"━", "FloatBorder"}, + {"┓", "FloatBorder"}, + {"┃", "FloatBorder"}, + {"┛", "FloatBorder"}, + {"━", "FloatBorder"}, + {"┗", "FloatBorder"}, + {"┃", "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 {} diff --git a/lua/theme.lua b/lua/theme.lua index e2a3b11..69cd227 100644 --- a/lua/theme.lua +++ b/lua/theme.lua @@ -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)