summaryrefslogtreecommitdiff
path: root/init.lua
blob: 2af6765a548a9facf3d4d65ec58ac58e8dfe32f5 (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
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
vim.loader.enable(true)

vim.g.mapleader = " "
vim.g.maplocalleader = ","

vim.g.clipboard = "osc52"

vim.g.loaded_2html_plugin = true
vim.g.loaded_fzf = 1 -- installed by arch
vim.g.loaded_gzip = 1
vim.g.loaded_matchit = 1
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.g.loaded_tarPlugin = 1
vim.g.loaded_tutor_mode_plugin = 1
vim.g.loaded_zipPlugin = 1
vim.g.loaded_zipPlugin = 1

vim.g.loaded_node_provider = 0
vim.g.loaded_perl_provider = 0
vim.g.loaded_python3_provider = 0
vim.g.loaded_ruby_provider = 0

vim.g.my_treesitter_langs = {
    "bash",
    "c",
    "cpp",
    "css",
    "diff",
    "html",
    "latex",
    "lua",
    "markdown",
    "markdown_inline",
    "python",
    "rust",
    "scss",
    "vim",
    "vimdoc",
    "yaml",
    "zig",
}

vim.api.nvim_create_autocmd("PackChanged", {
    callback = function(ev)
        -- only trigger on install or update
        if not vim.tbl_contains({ "install", "update" }, ev.data.kind) then
            return
        end

        local name, active = ev.data.spec.name, ev.data.active
        if name == "nvim-treesitter" then
            if not active then vim.cmd.packadd("nvim-treesitter") end
            local nts = require("nvim-treesitter")
            nts.install(vim.g.my_treesitter_langs, { summary = true })
            nts.update(nil, { summary = true })
        elseif name == "blink.cmp" then
            if not active then vim.cmd.packadd("blink.cmp") end
            require("mo.blink").build_rust()
        end
    end,
})

vim.pack.add({
    "https://github.com/nvim-treesitter/nvim-treesitter",
    "https://github.com/saghen/blink.cmp",
    -- "https://github.com/MeanderingProgrammer/render-markdown.nvim",
}, { load = false })

vim.pack.add({
    "https://github.com/folke/snacks.nvim", -- just for vim.ui.input
}, {
    load = function()
        vim.cmd([[packadd! snacks.nvim]])
        require("snacks").setup({
            image = { enabled = false },
            input = { enabled = true },
        })
        vim.cmd([[packadd snacks.nvim]])
    end,
})

vim.pack.add({
    "https://github.com/ibhagwan/fzf-lua",
}, {
    load = function()
        vim.api.nvim_create_user_command("FzfLua", function(data)
            vim.api.nvim_del_user_command("FzfLua")
            vim.cmd([[packadd fzf-lua]])
            require("mo.fzf")
            vim.cmd("FzfLua " .. data.args)
        end, { nargs = "?" })
    end,
})

vim.pack.add({
    "https://github.com/neovim/nvim-lspconfig",

    "https://github.com/moreka/alacritty.nvim",

    "https://github.com/tpope/vim-fugitive",
    "https://github.com/tpope/vim-surround",
    "https://github.com/tpope/vim-sleuth",

    "https://github.com/lewis6991/gitsigns.nvim",

    "https://github.com/stevearc/quicker.nvim",
    "https://github.com/stevearc/conform.nvim",

    "https://github.com/stevearc/oil.nvim",

    "https://github.com/nvim-mini/mini.nvim",

    "https://github.com/lervag/vimtex",
})

vim.pack.add({
    "https://github.com/nvim-orgmode/orgmode",
}, {
    load = function()
        vim.api.nvim_create_autocmd("FileType", {
            pattern = "org",
            once = true,
            callback = function()
                vim.cmd("packadd orgmode")
                require("mo.org")
            end,
        })
    end,
})

vim.api.nvim_create_autocmd("ColorScheme", {
    group = vim.api.nvim_create_augroup("init_config", {}),
    callback = function()
        for _, group in ipairs(vim.fn.getcompletion("@lsp", "highlight")) do
            vim.api.nvim_set_hl(0, group, {})
        end
    end,
})

if vim.env.VIM_LIGHT == "1" then
    vim.cmd.colorscheme("habarena")
else
    vim.cmd.colorscheme("notsoquiet")
    vim.o.cursorlineopt = "number"
end

require("vim._extui").enable({})

vim.lsp.config("*", {
    on_attach = function(client, _)
        -- NOTE: for nvim-cmp
        -- vim.cmd([[packadd cmp-nvim-lsp]])
        -- client.capabilities = require("cmp_nvim_lsp").default_capabilities()

        -- NOTE: for blink.cmp
        client.capabilities =
            require("blink.cmp").get_lsp_capabilities(client.capabilities, true)
    end,
})

vim.lsp.enable({
    -- "clangd",
    "emmylua_ls",
    "jsonls",
    -- "qmlls",
    "rust_analyzer",
    -- "ty",
})