LCOV - code coverage report
Current view: top level - /lua/yoda/filetype - settings.lua (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 76 76
Test Date: 2026-04-14 10:33:13 Functions: - 0 0

            Line data    Source code
       1              : -- lua/yoda/filetype/settings.lua
       2              : -- Filetype-specific settings and performance profiles
       3              : 
       4           14 : local M = {}
       5              : 
       6              : -- ============================================================================
       7              : -- Dependencies
       8              : -- ============================================================================
       9              : 
      10              : -- ============================================================================
      11              : -- Performance Profiles
      12              : -- ============================================================================
      13              : 
      14           14 : local PERFORMANCE_PROFILES = {
      15              :   aggressive = function()
      16            2 :     vim.opt_local.foldmethod = "manual"
      17            2 :     vim.opt_local.updatetime = 4000
      18            2 :     vim.opt_local.timeoutlen = 1000
      19            2 :     vim.opt_local.ttimeoutlen = 0
      20            2 :     vim.opt_local.lazyredraw = true
      21            2 :     vim.opt_local.synmaxcol = 200
      22            2 :     vim.opt_local.cursorline = false
      23            2 :     vim.opt_local.cursorcolumn = false
      24            2 :     vim.opt_local.relativenumber = false
      25           16 :   end,
      26              : 
      27              :   commit = function()
      28            2 :     vim.opt_local.foldmethod = "manual"
      29            2 :     vim.opt_local.updatetime = 2000
      30            2 :     vim.opt_local.lazyredraw = true
      31            2 :     vim.opt_local.synmaxcol = 200
      32            2 :     vim.opt_local.timeoutlen = 1000
      33            2 :     vim.opt_local.cursorline = false
      34            2 :     vim.opt_local.cursorcolumn = false
      35            2 :     vim.opt_local.relativenumber = false
      36            2 :     vim.opt_local.complete = ""
      37            2 :     vim.opt_local.completeopt = ""
      38           16 :   end,
      39              : 
      40              :   neogit = function()
      41              :     vim.opt_local.foldmethod = "manual"
      42              :     vim.opt_local.updatetime = 2000
      43              :     vim.opt_local.lazyredraw = true
      44              :     vim.opt_local.cursorline = false
      45              :     vim.opt_local.synmaxcol = 200
      46           14 :   end,
      47              : }
      48              : 
      49              : -- ============================================================================
      50              : -- Filetype-specific Settings
      51              : -- ============================================================================
      52              : 
      53           14 : local FILETYPE_SETTINGS = {
      54              :   markdown = function()
      55            2 :     PERFORMANCE_PROFILES.aggressive()
      56            2 :     vim.opt_local.wrap = true
      57            2 :     vim.opt_local.spell = false
      58            2 :     vim.opt_local.conceallevel = 0
      59            2 :     vim.opt_local.number = false
      60            2 :     vim.opt_local.colorcolumn = ""
      61           16 :   end,
      62              : 
      63              :   gitcommit = function()
      64            2 :     PERFORMANCE_PROFILES.commit()
      65            2 :     vim.opt_local.spell = true
      66            2 :     vim.opt_local.wrap = true
      67            2 :     vim.opt_local.textwidth = 72
      68           16 :   end,
      69              : 
      70              :   NeogitCommitMessage = function()
      71              :     PERFORMANCE_PROFILES.commit()
      72              :     vim.opt_local.spell = true
      73              :     vim.opt_local.wrap = true
      74              :     vim.opt_local.textwidth = 72
      75           14 :   end,
      76              : 
      77              :   NeogitStatus = function()
      78              :     PERFORMANCE_PROFILES.neogit()
      79           14 :   end,
      80              : 
      81              :   NeogitPopup = function()
      82              :     PERFORMANCE_PROFILES.neogit()
      83           14 :   end,
      84              : 
      85              :   ["snacks-explorer"] = function()
      86              :     -- Defer stopinsert until after the explorer buffer is fully settled;
      87              :     -- an immediate call fires before the mode is stable.
      88              :     vim.schedule(function()
      89              :       if vim.fn.mode() ~= "n" then
      90              :         vim.cmd("stopinsert")
      91              :       end
      92              :     end)
      93           14 :   end,
      94              : 
      95              :   -- Helm template files: use YAML syntax with helm-specific settings
      96              :   helm = function()
      97              :     vim.opt_local.commentstring = "# %s"
      98              :     vim.opt_local.syntax = "yaml" -- Use YAML syntax highlighting as base
      99              :     vim.opt_local.wrap = false
     100              :     vim.opt_local.expandtab = true
     101              :     vim.opt_local.shiftwidth = 2
     102              :     vim.opt_local.tabstop = 2
     103           14 :   end,
     104              : 
     105              :   -- Regular YAML files
     106              :   yaml = function()
     107            1 :     vim.opt_local.commentstring = "# %s"
     108            1 :     vim.opt_local.wrap = false
     109            1 :     vim.opt_local.expandtab = true
     110            1 :     vim.opt_local.shiftwidth = 2
     111            1 :     vim.opt_local.tabstop = 2
     112           15 :   end,
     113              : 
     114              :   -- Groovy files (including Jenkinsfiles)
     115              :   groovy = function()
     116            1 :     vim.opt_local.commentstring = "// %s"
     117            1 :     vim.opt_local.wrap = false
     118            1 :     vim.opt_local.expandtab = true
     119            1 :     vim.opt_local.shiftwidth = 4
     120            1 :     vim.opt_local.tabstop = 4
     121            1 :     vim.opt_local.softtabstop = 4
     122              :     -- Enable syntax highlighting
     123            1 :     vim.opt_local.syntax = "groovy"
     124           15 :   end,
     125              : 
     126              :   -- Properties files (disable treesitter, use simple syntax)
     127              :   properties = function()
     128              :     vim.opt_local.commentstring = "# %s"
     129              :     vim.opt_local.wrap = false
     130              :     vim.opt_local.expandtab = true
     131              :     vim.opt_local.shiftwidth = 2
     132              :     vim.opt_local.tabstop = 2
     133              :     -- Disable treesitter explicitly to prevent temp file errors
     134              :     vim.b.ts_highlight = false
     135              :     -- Use basic syntax highlighting
     136              :     vim.opt_local.syntax = "conf"
     137           14 :   end,
     138              : 
     139              :   -- Go files - 4 spaces indentation with proper auto-indent
     140              :   go = function()
     141              :     vim.opt_local.commentstring = "// %s"
     142              :     vim.opt_local.wrap = false
     143              :     vim.opt_local.expandtab = true
     144              :     vim.opt_local.shiftwidth = 4
     145              :     vim.opt_local.tabstop = 4
     146              :     vim.opt_local.softtabstop = 4
     147              : 
     148              :     -- Use cindent for Go - it works well with C-like syntax
     149              :     vim.opt_local.autoindent = true
     150              :     vim.opt_local.smartindent = false
     151              :     vim.opt_local.cindent = true
     152              : 
     153              :     -- Configure C-style indenting for Go
     154              :     vim.opt_local.cinkeys = "0{,0},0),0#,!^F,o,O,e,<:>"
     155              :     vim.opt_local.cinoptions = "L0,g0,N-s,E-s,t0,c1,C1,(0,ws,Ws,m1,j1,J1"
     156           14 :   end,
     157              : }
     158              : 
     159              : -- ============================================================================
     160              : -- Public API
     161              : -- ============================================================================
     162              : 
     163              : --- Apply filetype-specific settings
     164              : --- @param filetype string The filetype to configure
     165           14 : function M.apply(filetype)
     166           11 :   if type(filetype) ~= "string" or filetype == "" then
     167            4 :     return
     168              :   end
     169              : 
     170            7 :   local settings_fn = FILETYPE_SETTINGS[filetype]
     171            7 :   if settings_fn then
     172            6 :     settings_fn()
     173              :   end
     174           21 : end
     175              : 
     176              : --- Check if filetype has custom settings
     177              : --- @param filetype string The filetype to check
     178              : --- @return boolean
     179           14 : function M.has_settings(filetype)
     180            8 :   return FILETYPE_SETTINGS[filetype] ~= nil
     181           14 : end
     182              : 
     183              : --- Get list of supported filetypes
     184              : --- @return table
     185           14 : function M.get_supported_filetypes()
     186            3 :   local filetypes = {}
     187           36 :   for ft, _ in pairs(FILETYPE_SETTINGS) do
     188           33 :     table.insert(filetypes, ft)
     189              :   end
     190            3 :   table.sort(filetypes)
     191            3 :   return filetypes
     192           14 : end
     193              : 
     194           14 : return M
        

Generated by: LCOV version 2.0-1