aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/init.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/init.lua')
-rw-r--r--.config/nvim/init.lua174
1 files changed, 154 insertions, 20 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua
index 0d8bb5f..691f78b 100644
--- a/.config/nvim/init.lua
+++ b/.config/nvim/init.lua
@@ -1,20 +1,154 @@
--- Bootstrap lazy.nvim
-local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
-if not (vim.uv or vim.loop).fs_stat(lazypath) then
- local lazyrepo = "https://github.com/folke/lazy.nvim.git"
- local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
- if vim.v.shell_error ~= 0 then
- vim.api.nvim_echo({
- { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
- { out, "WarningMsg" },
- { "\nPress any key to exit..." },
- }, true, {})
- vim.fn.getchar()
- os.exit(1)
- end
-end
-vim.opt.rtp:prepend(lazypath)
-
--- Setup lazy.nvim
-require("vim-options")
-require("lazy").setup("plugins")
+vim.o.number = true
+vim.o.relativenumber = true
+vim.o.signcolumn = "yes"
+vim.o.wrap = false
+vim.o.tabstop = 2
+vim.o.shiftwidth = 2
+vim.o.softtabstop = 2
+vim.o.expandtab = true
+vim.o.swapfile = false
+vim.g.mapleader = " "
+vim.o.clipboard = "unnamedplus"
+vim.o.undofile = true
+vim.o.cursorline = false
+vim.o.title = true
+
+-- packages
+vim.pack.add({
+ { src = "https://github.com/sainnhe/everforest" },
+ { src = "https://github.com/nvim-lualine/lualine.nvim" },
+ { src = "https://github.com/lewis6991/gitsigns.nvim" },
+ { src = "https://github.com/cappyzawa/trim.nvim" },
+ { src = "https://github.com/nvim-treesitter/nvim-treesitter" },
+ { src = "https://github.com/lukas-reineke/indent-blankline.nvim" },
+ { src = "https://github.com/nvim-telescope/telescope.nvim" },
+ { src = "https://github.com/nvim-telescope/telescope-ui-select.nvim" },
+ { src = "https://github.com/nvim-lua/plenary.nvim" },
+ { src = "https://github.com/hrsh7th/cmp-nvim-lsp" },
+ { src = "https://github.com/hrsh7th/nvim-cmp" },
+ { src = "https://github.com/L3MON4D3/LuaSnip" },
+ { src = "https://github.com/saadparwaiz1/cmp_luasnip" },
+ { src = "https://github.com/rafamadriz/friendly-snippets" },
+})
+
+-- telescope
+local telescope = require("telescope")
+telescope.setup({
+ defaults = {
+ preview = { treesitter = false },
+ color_devicons = true,
+ sorting_strategy = "ascending",
+ borderchars = {
+ "─", -- top
+ "│", -- right
+ "─", -- bottom
+ "│", -- left
+ "┌", -- top-left
+ "┐", -- top-right
+ "┘", -- bottom-right
+ "└", -- bottom-left
+ },
+ path_displays = { "smart" },
+ layout_config = {
+ height = 100,
+ width = 400,
+ prompt_position = "top",
+ preview_cutoff = 40,
+ }
+ }
+})
+telescope.load_extension("ui-select")
+local builtin = require("telescope.builtin")
+
+-- binds
+vim.keymap.set('n', '<leader>lf', vim.lsp.buf.format)
+vim.api.nvim_set_keymap('n', ',c', ':w! | !compiler "%:p"<CR>', { noremap = true, silent = true })
+vim.keymap.set({ "n" }, "<leader>f", builtin.find_files, { desc = "Telescope live grep" })
+vim.keymap.set({ "n" }, "<leader>g", builtin.live_grep, { desc = "Telescope live grep" })
+
+-- lsp
+vim.lsp.enable({
+ "lua_ls", "clangd", "rust_analyzer", "bashls",
+ "html", "cssls", "jsonls", "yamlls"
+})
+
+vim.diagnostic.config({
+ virtual_text = {
+ prefix = '',
+ spacing = 4,
+ },
+ signs = {
+ text = {
+ [vim.diagnostic.severity.ERROR] = '',
+ [vim.diagnostic.severity.WARN] = '',
+ },
+ linehl = {
+ [vim.diagnostic.severity.ERROR] = 'ErrorMsg',
+ },
+ numhl = {
+ [vim.diagnostic.severity.WARN] = 'WarningMsg',
+ },
+ },
+ underline = true,
+ update_in_insert = true,
+ severity_sort = true,
+})
+
+-- plugins
+require('lualine').setup({})
+require("gitsigns").setup()
+require("trim").setup({})
+require("nvim-treesitter.configs").setup({
+ ensure_installed = {
+ "bash",
+ "lua",
+ "javascript",
+ "c",
+ "cpp",
+ "json",
+ "go",
+ "markdown",
+ "meson",
+ "make",
+ "cmake",
+ "python",
+ "rust",
+ "yaml",
+ "toml",
+ "ron",
+ },
+ highlight = { enable = true },
+ indent = { enable = true },
+})
+require("ibl").setup({})
+
+local cmp = require 'cmp'
+cmp.setup({
+ snippet = {
+ expand = function(args)
+ require('luasnip').lsp_expand(args.body)
+ end,
+ },
+ window = {
+ -- completion = cmp.config.window.bordered(),
+ -- documentation = cmp.config.window.bordered(),
+ },
+ mapping = cmp.mapping.preset.insert({
+ ['<C-b>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-f>'] = cmp.mapping.scroll_docs(4),
+ ['<C-Space>'] = cmp.mapping.complete(),
+ ['<C-e>'] = cmp.mapping.abort(),
+ ['<CR>'] = cmp.mapping.confirm({ select = true }),
+ }),
+ sources = cmp.config.sources({
+ { name = 'nvim_lsp' },
+ { name = 'luasnip' },
+ }, {
+ { name = 'buffer' },
+ })
+})
+
+-- theme
+-- vim.g.everforest_enable_italic = true
+-- vim.g.everforest_transparent_background = true
+vim.cmd("colorscheme everforest")