trying out nix
This commit is contained in:
commit
65bd68a260
18 changed files with 1217 additions and 0 deletions
144
init.lua
Normal file
144
init.lua
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
require("config.lazy")
|
||||
|
||||
local colorini = require('colorini')
|
||||
colorini.setup("green")
|
||||
|
||||
vim.opt.number = true
|
||||
vim.opt.wrap = false
|
||||
|
||||
vim.api.nvim_create_autocmd(
|
||||
{ "InsertEnter", "FocusLost", "BufLeave" },
|
||||
{
|
||||
callback = function()
|
||||
vim.opt.relativenumber = false
|
||||
end,
|
||||
}
|
||||
)
|
||||
|
||||
vim.api.nvim_create_autocmd(
|
||||
{ "InsertLeave", "FocusGained", "BufEnter" },
|
||||
{
|
||||
callback = function()
|
||||
vim.opt.relativenumber = true
|
||||
end,
|
||||
}
|
||||
)
|
||||
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.shiftwidth = 4
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.pumheight = 10
|
||||
vim.opt.pumwidth = 80
|
||||
vim.opt.cursorline = true
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
|
||||
vim.o.updatetime = 100
|
||||
|
||||
vim.keymap.set("n", "<Esc><Esc>", ":noh<CR>", { silent = true })
|
||||
vim.keymap.set("v", "ga", ":EasyAlign<CR>")
|
||||
vim.keymap.set("v", "<leader>c", '"+y', { desc = "Copy to system clipboard" })
|
||||
|
||||
function hex_to_rgb(hex)
|
||||
hex = hex:gsub("#", "")
|
||||
return tonumber(hex:sub(1,2),16), tonumber(hex:sub(3,4),16), tonumber(hex:sub(5,6),16)
|
||||
end
|
||||
|
||||
function rgb_to_hex(r, g, b)
|
||||
return string.format("#%02X%02X%02X", r,g,b)
|
||||
end
|
||||
|
||||
function shade_color(hex, factor)
|
||||
local r,g,b = hex_to_rgb(hex)
|
||||
r = math.floor(r * factor)
|
||||
g = math.floor(g * factor)
|
||||
b = math.floor(b * factor)
|
||||
return rgb_to_hex(r,g,b)
|
||||
end
|
||||
|
||||
local orange = "#fd971f"
|
||||
|
||||
function do_stuff()
|
||||
local highlights = vim.api.nvim_get_hl(0, {})
|
||||
for name, hl in pairs(highlights) do
|
||||
if hl.fg then
|
||||
local factor = hl.fg / 0xFFFFFF
|
||||
hl.fg = shade_color(orange, factor)
|
||||
hl.bold = true
|
||||
vim.api.nvim_set_hl(0, name, hl)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- TELESCOPE
|
||||
local builtin = require("telescope.builtin")
|
||||
vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Telescope find files" })
|
||||
vim.keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "Telescope live grep" })
|
||||
vim.keymap.set("n", "<leader>fb", builtin.buffers, { desc = "Telescope buffers" })
|
||||
vim.api.nvim_set_hl(0, "TelescopeSelection", { bg = "#2a2a2a", fg ="#ffffff" } )
|
||||
|
||||
vim.opt.termguicolors = true
|
||||
|
||||
-- LSP config
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
lspconfig.clangd.setup({
|
||||
cmd = { "clangd", "--background-index", "--compile-commands-dir=.", "--header-insertion=never" },
|
||||
root_dir = require("lspconfig.util").root_pattern("compile_commands.json", ".git"),
|
||||
capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
||||
})
|
||||
|
||||
lspconfig.rust_analyzer.setup({
|
||||
on_attach = function (client, bufnr)
|
||||
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
||||
end,
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
imports = {
|
||||
granularity = {
|
||||
group = "module",
|
||||
},
|
||||
prefix = "self",
|
||||
},
|
||||
cargo = {
|
||||
buildScripts = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
procMacro = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
vim.lsp.enable('gopls')
|
||||
-- vim.lsp.enable('rust-analyzer')
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
float = {
|
||||
border = "rounded",
|
||||
focusable = false,
|
||||
source = "always",
|
||||
scope = "line",
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
callback = function()
|
||||
vim.diagnostic.open_float(nil, {
|
||||
focusable = false,
|
||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
scope = "line",
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "<leader>ca", function()
|
||||
vim.lsp.buf.code_action()
|
||||
end, { desc = "Lsp code action" })
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue