~kris/dots

srice

ref: 94ef01abf339f7156c69870d969cd635566faddd srice/.config/code/init.lua -rw-r--r-- 5.2 KiB
94ef01ab — Kris Yotam remove nvim config, add mksh/planrc/gentoo profile, update code+write configs and fastfetch glenda 3 months ago
                                                                                
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
-- nvim coding config
-- Launch: NVIM_APPNAME=code nvim

vim.g.mapleader = " "

-- Disable netrw (snacks explorer replaces it)
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

-- Appearance
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.signcolumn = "yes"
vim.opt.termguicolors = true
vim.opt.cursorline = true
vim.opt.showmode = false
vim.opt.laststatus = 2
vim.opt.fillchars = { eob = " " }

-- Kill syntax highlighting
vim.cmd("syntax off")
vim.cmd("filetype plugin indent on")

-- Colorscheme
vim.cmd("colorscheme vacme")

-- Indentation
vim.opt.expandtab = true
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.smartindent = true
vim.opt.autoindent = true

-- Search
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.hlsearch = false
vim.opt.incsearch = true

-- Wrapping
vim.opt.wrap = false
vim.opt.scrolloff = 8
vim.opt.sidescrolloff = 8

-- Misc
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undofile = true
vim.opt.undodir = vim.fn.stdpath("data") .. "/undo"
vim.opt.clipboard = "unnamedplus"
vim.opt.mouse = "a"
vim.opt.updatetime = 250

-- snacks.nvim (explorer + project picker + dashboard)
require("snacks").setup({
  explorer = { enabled = true },
  picker = {
    enabled = true,
    sources = {
      projects = {
        dev = { "~/dev" },
        recent = false,
      },
    },
  },
  dashboard = {
    enabled = true,
    preset = {
      header = (function()
        local f = io.open(vim.fn.stdpath("config") .. "/glenda.txt", "r")
        if f then local s = f:read("*a"); f:close(); return s end
        return "code"
      end)(),
      keys = {
        { icon = " ", key = "f", desc = "Find File", action = ":lua Snacks.dashboard.pick('files')" },
        { icon = " ", key = "n", desc = "New File", action = ":ene | startinsert" },
        { icon = " ", key = "g", desc = "Find Text", action = ":lua Snacks.dashboard.pick('live_grep')" },
        { icon = " ", key = "r", desc = "Recent Files", action = ":lua Snacks.dashboard.pick('oldfiles')" },
        { icon = " ", key = "s", desc = "Browse src", action = ":e ~/.local/src/" },
        { icon = " ", key = "b", desc = "Browse scripts", action = ":e ~/.local/bin/" },
        { icon = " ", key = "i", desc = "mkshrc", action = ":e ~/.mkshrc" },
        { icon = " ", key = "p", desc = "plan9rc", action = ":e ~/.planrc" },
        { icon = " ", key = "a", desc = "aliases.sh", action = ":e ~/.config/mksh/aliases.sh" },
        { icon = " ", key = "u", desc = "functions.sh", action = ":e ~/.config/mksh/functions.sh" },
        { icon = " ", key = "e", desc = "Explorer", action = ":lua Snacks.explorer.open()" },
        { icon = " ", key = "q", desc = "Quit", action = ":qa" },
      },
    },
    sections = {
      { section = "header" },
      { section = "keys", gap = 1, padding = 1 },
    },
  },
})

-- gitsigns
require("gitsigns").setup({
  signs = {
    add = { text = "+" },
    change = { text = "~" },
    delete = { text = "_" },
    topdelete = { text = "-" },
    changedelete = { text = "~" },
  },
})

-- lualine (statusline)
require("lualine").setup({
  options = {
    theme = {
      normal = {
        a = { fg = "#424242", bg = "#EAFFFF", gui = "bold" },
        b = { fg = "#424242", bg = "#EAEBDB" },
        c = { fg = "#424242", bg = "#FFFFEC" },
      },
      insert = {
        a = { fg = "#424242", bg = "#EFFEEC", gui = "bold" },
      },
      visual = {
        a = { fg = "#424242", bg = "#EEEEA7", gui = "bold" },
      },
      command = {
        a = { fg = "#424242", bg = "#D0D0F7", gui = "bold" },
      },
      inactive = {
        c = { fg = "#999957", bg = "#FFFFEC" },
      },
    },
    icons_enabled = false,
    component_separators = { left = "|", right = "|" },
    section_separators = { left = "", right = "" },
  },
  sections = {
    lualine_a = { "mode" },
    lualine_b = { "branch" },
    lualine_c = { "filename" },
    lualine_x = { "filetype" },
    lualine_y = { "progress" },
    lualine_z = { "location" },
  },
})

-- Keymaps
local map = vim.keymap.set

-- Explorer
map("n", "<leader>e", function() Snacks.explorer.open() end, { desc = "Toggle file explorer" })

-- Project switcher (browse ~/dev directories)
map("n", "<leader>fp", function()
  local dev_root = vim.fn.expand("~/dev")
  Snacks.picker.files({
    cwd = dev_root,
    cmd = "fd",
    args = { "--type", "d", "--max-depth", "1" },
    confirm = function(picker, item)
      picker:close()
      if item then
        local dir = dev_root .. "/" .. item.text:gsub("/$", "")
        vim.cmd("cd " .. vim.fn.fnameescape(dir))
        Snacks.picker.files({ cwd = dir })
      end
    end,
  })
end, { desc = "Switch project" })

-- File search
map("n", "<leader>sf", function() Snacks.picker.files() end, { desc = "Search files" })
map("n", "<leader>fg", function() Snacks.picker.grep() end, { desc = "Grep" })
map("n", "<leader>ff", function() Snacks.picker.smart() end, { desc = "Smart find" })
map("n", "<leader>s.", function() Snacks.picker.recent() end, { desc = "Recent files" })
map("n", "<leader><leader>", function() Snacks.picker.buffers() end, { desc = "Buffers" })
map("n", "<leader>/", function() Snacks.picker.lines() end, { desc = "Search in buffer" })

-- Basics
map("n", "<leader>w", "<cmd>w<cr>", { desc = "Save" })
map("n", "<leader>q", "<cmd>q<cr>", { desc = "Quit" })