299 lines
6 KiB
Lua
299 lines
6 KiB
Lua
|
--[[ CONFIG ]]--
|
||
|
|
||
|
-- global config for iris configuration
|
||
|
config = {
|
||
|
-- colorscheme for nvim
|
||
|
colorscheme = "catppuccin",
|
||
|
flavour = "mocha",
|
||
|
-- indentation
|
||
|
tab_width = 4,
|
||
|
expand_tab = false,
|
||
|
-- keybinds to be set to actions
|
||
|
keybinds = {
|
||
|
-- leader key
|
||
|
leader = ' ',
|
||
|
-- toggle menus
|
||
|
menus = {
|
||
|
-- file browser
|
||
|
browser = '<leader>e',
|
||
|
-- active buffers
|
||
|
buffers = '<leader>fb',
|
||
|
-- error list
|
||
|
error = '<leader>t',
|
||
|
-- find files
|
||
|
find = '<leader>ff',
|
||
|
-- grep files
|
||
|
grep = '<leader>fg',
|
||
|
-- help browser
|
||
|
help = '<leader>fh',
|
||
|
-- undo tree
|
||
|
undo = '<leader>u',
|
||
|
},
|
||
|
-- lsp actions
|
||
|
lsp = {
|
||
|
hover = 'K',
|
||
|
action = '<leader>la',
|
||
|
references = '<leader>lr',
|
||
|
rename = '<leader>ln',
|
||
|
},
|
||
|
-- completion
|
||
|
cmp = {
|
||
|
-- prev item
|
||
|
prev = '<C-p>',
|
||
|
-- next item
|
||
|
next = '<C-n>',
|
||
|
-- confirm
|
||
|
confirm = '<CR>',
|
||
|
-- complete
|
||
|
complete = '<C-Space>',
|
||
|
},
|
||
|
-- disable active selection
|
||
|
noh = '<leader>h',
|
||
|
},
|
||
|
-- treesitter languages
|
||
|
treesitter = {
|
||
|
"c",
|
||
|
"lua",
|
||
|
"rust",
|
||
|
"typescript",
|
||
|
"javascript",
|
||
|
"python",
|
||
|
"vim",
|
||
|
"vimdoc",
|
||
|
"query",
|
||
|
},
|
||
|
-- lsp servers
|
||
|
lsps = {
|
||
|
-- rust
|
||
|
rust_analyzer = {},
|
||
|
-- c / c++
|
||
|
clangd = {},
|
||
|
-- java
|
||
|
jdtls = {},
|
||
|
},
|
||
|
};
|
||
|
|
||
|
vim.call('iris#load')
|
||
|
|
||
|
--[[ IMPORTS ]]--
|
||
|
|
||
|
local catppuccin = require('catppuccin')
|
||
|
|
||
|
--[[ VIM ]]--
|
||
|
|
||
|
vim.opt.tabstop = config.tab_width
|
||
|
vim.opt.softtabstop = config.tab_width
|
||
|
vim.opt.shiftwidth = config.tab_width
|
||
|
vim.opt.expandtab = config.expand_tab
|
||
|
vim.opt.mouse = "a"
|
||
|
vim.opt.clipboard = "unnamedplus"
|
||
|
vim.opt.hlsearch = true
|
||
|
vim.opt.autoindent = true
|
||
|
vim.opt.ttyfast = true
|
||
|
vim.opt.number = true
|
||
|
vim.opt.relativenumber = true
|
||
|
vim.opt.rnu = true
|
||
|
vim.opt.swapfile = false
|
||
|
vim.opt.termguicolors = true
|
||
|
|
||
|
-- remove trailing whitespace on save
|
||
|
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
||
|
pattern = { "*" },
|
||
|
command = [[%s/\s\+$//e]],
|
||
|
})
|
||
|
|
||
|
--[[ THEME ]]--
|
||
|
|
||
|
catppuccin.setup({
|
||
|
flavour = config.flavour,
|
||
|
transparent_background = true,
|
||
|
integrations = {
|
||
|
cmp = true,
|
||
|
illuminate = {
|
||
|
enabled = true,
|
||
|
lsp = false
|
||
|
},
|
||
|
nvimtree = true,
|
||
|
nvim_surround = true,
|
||
|
lsp_trouble = true,
|
||
|
telescope = {
|
||
|
enabled = true,
|
||
|
},
|
||
|
treesitter = true,
|
||
|
},
|
||
|
})
|
||
|
|
||
|
vim.cmd('colorscheme ' .. config.colorscheme)
|
||
|
vim.o.background = "dark"
|
||
|
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
|
||
|
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
|
||
|
vim.api.nvim_set_hl(0, "NvimTreeNormal", { bg = "none" })
|
||
|
|
||
|
--[[ LINES ]]--
|
||
|
|
||
|
-- mode line
|
||
|
require('lualine').setup {
|
||
|
options = {
|
||
|
theme = config.colorscheme,
|
||
|
icons_enabled = true,
|
||
|
globalstatus = true,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
-- buffer line
|
||
|
require("bufferline").setup {}
|
||
|
|
||
|
--[[ MENUS ]]--
|
||
|
|
||
|
-- file browser
|
||
|
vim.g.loaded_netrw = 1
|
||
|
vim.g.loaded_netrwPlugin = 1
|
||
|
vim.opt.termguicolors = true
|
||
|
|
||
|
require("nvim-tree").setup {
|
||
|
sort = {
|
||
|
sorter = "case_sensitive",
|
||
|
},
|
||
|
view = {
|
||
|
width = 30,
|
||
|
},
|
||
|
renderer = {
|
||
|
group_empty = true,
|
||
|
},
|
||
|
actions = {
|
||
|
open_file = {
|
||
|
quit_on_open = true,
|
||
|
},
|
||
|
},
|
||
|
filters = {
|
||
|
dotfiles = false,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
--[[ COMPLETION ]]--
|
||
|
|
||
|
-- completion engine
|
||
|
--local cmp = require('cmp')
|
||
|
--
|
||
|
--local cmp_select = {behavior = cmp.SelectBehavior.Select}
|
||
|
--local cmp_mappings = cmp.mapping.preset.insert({
|
||
|
-- [config.keybinds.cmp.prev] = cmp.mapping.select_prev_item(cmp_select),
|
||
|
-- [config.keybinds.cmp.next] = cmp.mapping.select_next_item(cmp_select),
|
||
|
-- [config.keybinds.cmp.confirm] = cmp.mapping.confirm({ select = true }),
|
||
|
-- [config.keybinds.cmp.complete] = cmp.mapping.complete(),
|
||
|
--})
|
||
|
--
|
||
|
--cmp_mappings['<Tab>'] = nil
|
||
|
--cmp_mappings['<S-Tab>'] = nil
|
||
|
--
|
||
|
--cmp.setup {
|
||
|
-- snippet = {
|
||
|
-- expand = function(args)
|
||
|
-- vim.fn["vsnip#anonymous"](args.body)
|
||
|
-- end,
|
||
|
-- },
|
||
|
-- sources = cmp.config.sources({
|
||
|
-- { name = 'nvim_lsp' },
|
||
|
-- { name = 'vsnip' },
|
||
|
-- { name = 'buffer' },
|
||
|
-- }),
|
||
|
-- mapping = cmp_mappings,
|
||
|
--}
|
||
|
--
|
||
|
-- delimiter completion
|
||
|
require'nvim-surround'.setup {}
|
||
|
|
||
|
--[[ LSP ]]--
|
||
|
|
||
|
local capabilities = require'cmp_nvim_lsp'.default_capabilities()
|
||
|
for lsp,config in pairs(config.lsps) do
|
||
|
config.capabilities = capabilities
|
||
|
require'lspconfig'[lsp].setup(config)
|
||
|
end
|
||
|
|
||
|
-- treesitter
|
||
|
require'nvim-treesitter.configs'.setup {
|
||
|
ensure_installed = config.treesitter,
|
||
|
sync_install = false,
|
||
|
auto_install = true,
|
||
|
highlight = {
|
||
|
enable = true,
|
||
|
additional_vim_regex_highlighting = false,
|
||
|
},
|
||
|
indent = {
|
||
|
enable = true
|
||
|
},
|
||
|
}
|
||
|
|
||
|
-- illuminate
|
||
|
require'illuminate'.configure {
|
||
|
providers = {
|
||
|
'lsp',
|
||
|
'treesitter',
|
||
|
'regex',
|
||
|
},
|
||
|
}
|
||
|
|
||
|
-- todo comments
|
||
|
require('todo-comments').setup()
|
||
|
|
||
|
-- auto indentation
|
||
|
require('indent-o-matic').setup {
|
||
|
max_lines = 2048,
|
||
|
standard_widths = { 2, 4, 8 },
|
||
|
skip_multiline = true,
|
||
|
}
|
||
|
|
||
|
-- image viewer
|
||
|
--require'hologram'.setup {
|
||
|
-- auto_display = true
|
||
|
--}
|
||
|
|
||
|
-- 80 col bar
|
||
|
require'virt-column'.setup {
|
||
|
enabled = true,
|
||
|
virtcolumn = "80"
|
||
|
}
|
||
|
|
||
|
-- notifications
|
||
|
require("fidget").setup {
|
||
|
notification = {
|
||
|
window = {
|
||
|
winblend = 0,
|
||
|
},
|
||
|
},
|
||
|
}
|
||
|
|
||
|
--[[ KEYBINDS ]]--
|
||
|
|
||
|
vim.g.mapleader = config.keybinds.leader
|
||
|
vim.g.maplocalleader = config.keybinds.leader
|
||
|
vim.keymap.set('', '<leader>', '<Nop>', { noremap = true, silent = true })
|
||
|
|
||
|
local function bind(key, action, opts)
|
||
|
opts = opts or {}
|
||
|
vim.keymap.set('n', key, action, opts)
|
||
|
end
|
||
|
|
||
|
bind(config.keybinds.noh, vim.cmd.noh)
|
||
|
bind(config.keybinds.menus.browser, vim.cmd.NvimTreeToggle)
|
||
|
bind(config.keybinds.menus.undo, vim.cmd.UndotreeToggle)
|
||
|
bind(config.keybinds.menus.error, function() require'trouble'.toggle() end)
|
||
|
|
||
|
local telescope = require'telescope.builtin'
|
||
|
bind(config.keybinds.menus.buffers, telescope.buffers)
|
||
|
bind(config.keybinds.menus.find, telescope.find_files)
|
||
|
bind(config.keybinds.menus.grep, telescope.live_grep)
|
||
|
bind(config.keybinds.menus.help, telescope.help_tags)
|
||
|
|
||
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||
|
desc = 'LSP actions',
|
||
|
callback = function(event)
|
||
|
local opts = {buffer = event.buf}
|
||
|
bind(config.keybinds.lsp.hover, function() vim.lsp.buf.hover() end, opts)
|
||
|
bind(config.keybinds.lsp.action, function() vim.lsp.buf.code_action() end, opts)
|
||
|
bind(config.keybinds.lsp.references, function() vim.lsp.buf.references() end, opts)
|
||
|
bind(config.keybinds.lsp.rename, function() vim.lsp.buf.rename() end, opts)
|
||
|
end
|
||
|
})
|