about summary refs log tree commit diff
path: root/.config/nvim/lua/config/options.lua
blob: fd1de926c0da6124c66ef66b62643e2f9d19ced3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
vim.opt.nu = true
vim.opt.rnu = true

vim.opt.tabstop = 2
vim.opt.softtabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.autoindent = true

vim.opt.smartindent = true

vim.opt.wrap = false

vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.nvim/undodir"
vim.opt.undofile = true

vim.opt.hlsearch = false
vim.opt.incsearch = true

vim.opt.termguicolors = true

vim.opt.scrolloff = 12

vim.opt.updatetime = 50

vim.opt.splitbelow = true
vim.opt.splitright = true

vim.opt.encoding = "utf-8"

vim.opt.shell = "zsh"

vim.opt.mouse = "a"

vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.incsearch = true

-- vim.opt.cursorline = true

vim.opt.title = true

vim.opt.clipboard = "unnamedplus"

vim.opt.colorcolumn = "80"

vim.opt.signcolumn = 'no'

vim.cmd "set showtabline=0 | set laststatus=0"

vim.wo.fillchars='eob: '

vim.opt.conceallevel = 3

-- Window Borders
vim.o.winborder = 'rounded'

-- Remove Whitespaces on File Save
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
  pattern = { "*" },
  command = [[%s/\s\+$//e]],
})

-- Define highlight groups for line numbers with diagnostics
vim.api.nvim_set_hl(0, "LineNrDiagnosticError", { bg = "#3f1d1d", fg = "#ff6c6b" })
vim.api.nvim_set_hl(0, "LineNrDiagnosticWarn",  { bg = "#3f311d", fg = "#ECBE7B" })
vim.api.nvim_set_hl(0, "LineNrDiagnosticInfo",  { bg = "#1d2d3f", fg = "#51afef" })
vim.api.nvim_set_hl(0, "LineNrDiagnosticHint",  { bg = "#1d3f2d", fg = "#98be65" })

local function set_line_number_highlight()
  -- Clear existing highlights
  vim.fn.sign_unplace("LineNrDiagnostics")

  -- Get diagnostics per buffer
  for _, diag in ipairs(vim.diagnostic.get(0)) do
    local hl_group = nil
    if diag.severity == vim.diagnostic.severity.ERROR then
      hl_group = "LineNrDiagnosticError"
    elseif diag.severity == vim.diagnostic.severity.WARN then
      hl_group = "LineNrDiagnosticWarn"
    elseif diag.severity == vim.diagnostic.severity.INFO then
      hl_group = "LineNrDiagnosticInfo"
    elseif diag.severity == vim.diagnostic.severity.HINT then
      hl_group = "LineNrDiagnosticHint"
    end

    if hl_group then
      vim.fn.sign_place(0, "LineNrDiagnostics", hl_group, vim.api.nvim_get_current_buf(), {
        lnum = diag.lnum + 1, -- diagnostics are 0-indexed
        priority = 10,
      })
    end
  end
end

-- Create the sign definitions
vim.fn.sign_define("LineNrDiagnosticError", { text = "", texthl = "LineNrDiagnosticError", numhl = "LineNrDiagnosticError" })
vim.fn.sign_define("LineNrDiagnosticWarn",  { text = "", texthl = "LineNrDiagnosticWarn",  numhl = "LineNrDiagnosticWarn"  })
vim.fn.sign_define("LineNrDiagnosticInfo",  { text = "", texthl = "LineNrDiagnosticInfo",  numhl = "LineNrDiagnosticInfo"  })
vim.fn.sign_define("LineNrDiagnosticHint",  { text = "", texthl = "LineNrDiagnosticHint",  numhl = "LineNrDiagnosticHint"  })

-- Update line numbers when diagnostics change
vim.api.nvim_create_autocmd({ "DiagnosticChanged", "BufEnter", "CursorHold" }, {
  callback = set_line_number_highlight,
})

-- TODO: Put somewhere else (for llm.nvim)
vim.fn.setenv("LLM_KEY", "NONE")