|
|
|
|
@@ -1,34 +1,27 @@
|
|
|
|
|
-- SECTION: Options
|
|
|
|
|
vim.o.number = true -- Show line numbers
|
|
|
|
|
vim.o.wrap = true -- Soft-wrap lines
|
|
|
|
|
vim.o.tabstop = 2 -- 2 space tab width
|
|
|
|
|
vim.o.shiftwidth = 2 -- 2 space tab width
|
|
|
|
|
vim.o.swapfile = false -- Disable swap files (annoying)
|
|
|
|
|
vim.o.undofile = true -- Enable undo between sessions
|
|
|
|
|
vim.o.mouse = 'a' -- Enable mouse support
|
|
|
|
|
vim.o.showmode = false -- Don't show mode in status bar
|
|
|
|
|
vim.o.inccommand = 'split' -- Preview replace commands inline
|
|
|
|
|
vim.o.scrolloff = 20 -- Scroll if cursor is X lines to edge
|
|
|
|
|
vim.o.confirm = true -- Add confirmation on some destructive actions
|
|
|
|
|
vim.o.ignorecase = true -- Case insensitive search
|
|
|
|
|
vim.o.smartcase = true -- Case sensitive when caps is used
|
|
|
|
|
vim.o.cursorline = true -- Highlight current line
|
|
|
|
|
vim.o.winborder = "single" -- Borders around popups like when you press leader for keybinds
|
|
|
|
|
vim.o.number = true -- Show line numbers
|
|
|
|
|
vim.o.wrap = true -- Soft-wrap lines
|
|
|
|
|
vim.o.tabstop = 2 -- 2 space tab width
|
|
|
|
|
vim.o.shiftwidth = 2 -- 2 space tab width
|
|
|
|
|
vim.o.swapfile = false -- Disable swap files (annoying)
|
|
|
|
|
vim.o.undofile = true -- Enable undo between sessions
|
|
|
|
|
vim.o.mouse = 'a' -- Enable mouse support
|
|
|
|
|
vim.o.showmode = false -- Don't show mode in status bar
|
|
|
|
|
vim.o.inccommand = 'split' -- Preview replace commands inline
|
|
|
|
|
vim.o.scrolloff = 20 -- Scroll if cursor is X lines to edge
|
|
|
|
|
vim.o.confirm = true -- Add confirmation on some destructive actions
|
|
|
|
|
vim.o.ignorecase = true -- Case insensitive search
|
|
|
|
|
vim.o.smartcase = true -- Case sensitive when caps is used
|
|
|
|
|
vim.o.cursorline = true -- Highlight current line
|
|
|
|
|
vim.o.winborder = "single" -- Borders around popups like when you press leader for keybinds
|
|
|
|
|
vim.opt.signcolumn =
|
|
|
|
|
'yes' -- TEST: Prohibit layout shifting by always showing the sign column (left of line numbers), you should see an icon there on this row.
|
|
|
|
|
vim.o.autocomplete = true -- Turn on builtin autocomplete
|
|
|
|
|
vim.o.complete = "o,.,w,b,u" -- Indicates what kind of items to show in the autocomplete
|
|
|
|
|
vim.o.completeopt = "fuzzy,menuone,noselect,popup" -- Options for autocomplete
|
|
|
|
|
vim.o.pumheight = 7 -- Max items to show in autocomplete
|
|
|
|
|
vim.o.pummaxwidth = 80 -- Max width of autocomplete
|
|
|
|
|
'yes' -- TEST: Prohibit layout shifting by always showing the sign column (left of line numbers), you should see an icon there on this row.
|
|
|
|
|
vim.o.updatetime = 250
|
|
|
|
|
vim.o.timeoutlen = 300
|
|
|
|
|
|
|
|
|
|
-- SECTION: Globals
|
|
|
|
|
vim.g.mapleader = ' ' -- Mapping leader to space.
|
|
|
|
|
vim.g.maplocalleader = ' ' -- Mapping leader to space.
|
|
|
|
|
vim.g.have_nerd_font = true -- Enable nerd font
|
|
|
|
|
|
|
|
|
|
-- SECTION: Lazy settings
|
|
|
|
|
-- INFO: Lines in this function will be executed after main event loop is free, prohibiting startup lag.
|
|
|
|
|
vim.schedule(function()
|
|
|
|
|
@@ -50,18 +43,26 @@ vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
|
|
|
|
vim.keymap.set('n', '<leader>f', vim.lsp.buf.format, { desc = "Format buffer" })
|
|
|
|
|
|
|
|
|
|
-- Start the file picker in different modes
|
|
|
|
|
vim.keymap.set('n', '<leader>sf', ":Pick files<CR>", { desc = "Search files" })
|
|
|
|
|
vim.keymap.set('n', '<leader>sg', ":Pick grep_live<CR>", { desc = "Search files" })
|
|
|
|
|
vim.keymap.set('n', '<leader>sf', function()
|
|
|
|
|
require('mini.pick').builtin.files()
|
|
|
|
|
end, { desc = "Search files" })
|
|
|
|
|
vim.keymap.set('n', '<leader>sg', ":Pick grep_live<CR>", { desc = "Search file contents" })
|
|
|
|
|
|
|
|
|
|
-- Get help with keybinds
|
|
|
|
|
vim.keymap.set('n', '<leader>?', ":WhichKey<CR>", { desc = "Show keybinds" })
|
|
|
|
|
|
|
|
|
|
-- File explorer
|
|
|
|
|
vim.keymap.set('n', '\\', ":Oil --float<CR>", { desc = "File explorer" })
|
|
|
|
|
|
|
|
|
|
-- SECTION: Install packages
|
|
|
|
|
vim.pack.add({
|
|
|
|
|
'https://github.com/catppuccin/nvim', -- color scheme
|
|
|
|
|
'https://github.com/nvim-mini/mini.pick', -- File picker, grep
|
|
|
|
|
'https://github.com/nvim-mini/mini.pairs', -- Auto create {}, (), [] - pairs etc.
|
|
|
|
|
'https://github.com/nvim-mini/mini.notify', -- Popup notifications
|
|
|
|
|
'https://github.com/nvim-mini/mini.completion', -- Autocomplete, needs snippets and icons
|
|
|
|
|
'https://github.com/nvim-mini/mini.snippets', -- Snippets
|
|
|
|
|
'https://github.com/nvim-mini/mini.icons', -- Icons
|
|
|
|
|
'https://github.com/neovim/nvim-lspconfig', -- Language servers
|
|
|
|
|
'https://github.com/mason-org/mason.nvim', -- LSP deps installer
|
|
|
|
|
'https://github.com/mason-org/mason-lspconfig.nvim', -- Lets you install mason tooling using lsp names
|
|
|
|
|
@@ -70,8 +71,8 @@ vim.pack.add({
|
|
|
|
|
'https://github.com/folke/which-key.nvim', -- Shortcut hints (bar at the bottom when pressing space)
|
|
|
|
|
'https://github.com/nvim-lua/plenary.nvim', -- Helper lua functions, dep of todo-comments.
|
|
|
|
|
'https://github.com/folke/todo-comments.nvim', -- Helper lua functions, dep of todo-comments.
|
|
|
|
|
'https://github.com/nvim-treesitter/nvim-treesitter',
|
|
|
|
|
|
|
|
|
|
'https://github.com/nvim-treesitter/nvim-treesitter', -- Syntax highlighting
|
|
|
|
|
'https://github.com/stevearc/oil.nvim', -- File explorer
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- SECTION: Colorscheme
|
|
|
|
|
@@ -99,9 +100,20 @@ require('todo-comments').setup({
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- Mini
|
|
|
|
|
require('mini.pick').setup()
|
|
|
|
|
local MiniPicker = require('mini.pick').setup({
|
|
|
|
|
source = {
|
|
|
|
|
show = require('mini.pick').default_show,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
require('mini.pairs').setup()
|
|
|
|
|
require('mini.notify').setup()
|
|
|
|
|
require('mini.icons').setup()
|
|
|
|
|
MiniIcons.tweak_lsp_kind()
|
|
|
|
|
require('mini.snippets').setup()
|
|
|
|
|
require('mini.completion').setup()
|
|
|
|
|
|
|
|
|
|
require('oil').setup()
|
|
|
|
|
|
|
|
|
|
require('nvim-treesitter').setup({
|
|
|
|
|
auto_install = true
|
|
|
|
|
@@ -111,7 +123,7 @@ require('nvim-treesitter').setup({
|
|
|
|
|
require("mason").setup()
|
|
|
|
|
require("mason-lspconfig").setup({
|
|
|
|
|
-- Install lsp deps here
|
|
|
|
|
ensure_installed = { 'lua_ls' },
|
|
|
|
|
ensure_installed = { 'lua_ls', 'ts_ls', 'ansiblels', 'eslint' },
|
|
|
|
|
automatic_enable = true
|
|
|
|
|
})
|
|
|
|
|
require("mason-tool-installer").setup({
|
|
|
|
|
@@ -122,6 +134,15 @@ require("mason-tool-installer").setup({
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- SECTION: Helpers
|
|
|
|
|
local function client_supports_method(client, method, bufnr)
|
|
|
|
|
if vim.fn.has 'nvim-0.11' == 1 then
|
|
|
|
|
return client:supports_method(method, bufnr)
|
|
|
|
|
else
|
|
|
|
|
return client.supports_method(method, { bufnr = bufnr })
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- SECTION: Autocommands
|
|
|
|
|
vim.api.nvim_create_autocmd('TextYankPost', {
|
|
|
|
|
desc = 'Highlight when yanking (copying) text',
|
|
|
|
|
@@ -130,26 +151,12 @@ vim.api.nvim_create_autocmd('TextYankPost', {
|
|
|
|
|
vim.highlight.on_yank()
|
|
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- Actions on LspAttach
|
|
|
|
|
vim.api.nvim_create_autocmd('LspAttach', {
|
|
|
|
|
group = vim.api.nvim_create_augroup('my.lsp', {}),
|
|
|
|
|
callback = function(ev)
|
|
|
|
|
-- INFO: Helpers
|
|
|
|
|
local function client_supports_method(client, method, bufnr)
|
|
|
|
|
if vim.fn.has 'nvim-0.11' == 1 then
|
|
|
|
|
return client:supports_method(method, bufnr)
|
|
|
|
|
else
|
|
|
|
|
return client.supports_method(method, { bufnr = bufnr })
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local client = assert(vim.lsp.get_client_by_id(ev.data.client_id))
|
|
|
|
|
|
|
|
|
|
-- Enable auto-completion
|
|
|
|
|
if client:supports_method('textDocument/completion') then
|
|
|
|
|
vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true })
|
|
|
|
|
end
|
|
|
|
|
-- Auto-format ("lint") on save.
|
|
|
|
|
-- Usually not needed if server supports "textDocument/willSaveWaitUntil".
|
|
|
|
|
if not client:supports_method('textDocument/willSaveWaitUntil')
|
|
|
|
|
|