summaryrefslogtreecommitdiff
path: root/dot-config/nvim/init.lua
blob: d415d8bebe33938166a2a11d5e49038e4a3c7ce5 (plain) (blame)
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
-- Settings
local set = vim.o

set.et = true
set.sw = 4
set.sts = -1
set.ts = 4
set.nu = true
set.signcolumn = "yes"
set.updatetime = 1000
set.ignorecase = true
set.smartcase = true
set.backup = false
set.undodir = vim.fn.stdpath("data") .. "/undodir"
set.undofile = true
set.splitright = true
set.splitbelow = true
set.breakindent = true
set.termguicolors = true
set.linebreak = true

vim.g.omni_sql_no_default_maps = 1337
-- vim.g.asmsyntax = "nasm"

vim.api.nvim_create_autocmd("TermOpen", {
    group = vim.api.nvim_create_augroup("TermNoNumbers", {}),
    command = "setlocal nonu nornu signcolumn=no"
})

vim.api.nvim_create_autocmd("TextYankPost", {
    group = vim.api.nvim_create_augroup("HighlightYank", {}),
    callback = function() vim.highlight.on_yank() end,
})

-- Plugins
vim.pack.add({
    { name = "catppuccin", src = "https://github.com/catppuccin/nvim" },
    "https://github.com/stevearc/oil.nvim",
    "https://github.com/nvim-mini/mini.icons",
    "https://github.com/nvim-treesitter/nvim-treesitter",
    "https://github.com/neovim/nvim-lspconfig",
})

require "catppuccin".setup {
    background = { light = "latte", dark = "mocha" },
}
vim.cmd.colorscheme("catppuccin")

require "oil".setup {
    columns = {
        "icon",
        "permissions",
        "size",
        "mtime",
    },
    delete_to_trash = true,
}

require "mini.icons".setup()
local treesitter = require "nvim-treesitter"
treesitter.setup()
local treesitter_languages = { "typescript", "zig" }
treesitter.install(treesitter_languages)

vim.api.nvim_create_autocmd("FileType", {
    pattern = treesitter_languages,
    callback = function()
        vim.treesitter.start()
        vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
    end,
})

-- LSP
vim.lsp.enable({ "ts_ls" })

vim.diagnostic.config({
    virtual_text = true,
    virtual_lines = { current_line = true },
})

vim.filetype.add({
    filename = {
        ["compose.yaml"] = "yaml.docker-compose",
        ["docker-compose.yaml"] = "yaml.docker-compose",
    },
    extension = {
        templ = "templ",
        typ = "typst",
    }
})

-- Keymaps
for _, mod in ipairs({
    function(x) return x end,
    function(x) return "<c-w>" .. x end,
    function(x) return "<c-w><c-" .. x .. ">" end,
    function(x) return string.upper(x) end,
}) do
    vim.keymap.set("", mod("n"), mod("j"))
    vim.keymap.set("", mod("e"), mod("k"))
    vim.keymap.set("", mod("k"), mod("n"))
    vim.keymap.set("", mod("j"), mod("e"))
end

vim.g.mapleader = " "
vim.keymap.set("n", "<leader>h", function() set.hls = not set.hls end)
vim.keymap.set("n", "<space>", "<nop>", { silent = true })
vim.keymap.set("n", "-", vim.cmd.Oil)