updated neovim config
This commit is contained in:
607
nvim/init.lua
607
nvim/init.lua
@@ -1,69 +1,74 @@
|
|||||||
vim.o.number = true
|
-- ============================================================================
|
||||||
vim.o.wrap = false
|
-- === NEOVIM CONFIGURATION ===================================================
|
||||||
vim.o.tabstop = 4
|
-- ============================================================================
|
||||||
vim.o.shiftwidth = 4
|
|
||||||
|
-- ============================================================================
|
||||||
|
-- 1. CORE SETTINGS
|
||||||
|
-- ============================================================================
|
||||||
|
vim.g.mapleader = "," -- Set leader key to comma
|
||||||
|
|
||||||
|
vim.o.number = true -- Show absolute line numbers
|
||||||
|
vim.o.wrap = false -- Disable line wrapping globally
|
||||||
|
vim.o.tabstop = 4 -- Width of a raw <Tab> character
|
||||||
|
vim.o.shiftwidth = 4 -- Number of spaces used for autoindent
|
||||||
vim.o.expandtab = true -- Use spaces instead of tabs
|
vim.o.expandtab = true -- Use spaces instead of tabs
|
||||||
vim.o.smartcase = true
|
vim.o.smartcase = true -- Override ignorecase if search contains uppercase
|
||||||
vim.o.ignorecase = true
|
vim.o.ignorecase = true -- Case-insensitive searching
|
||||||
vim.o.hlsearch = false
|
vim.o.hlsearch = false -- Disable persistent search highlighting
|
||||||
vim.o.signcolumn = "yes"
|
vim.o.signcolumn = "yes" -- Always show the sign column (prevents text shifting)
|
||||||
vim.o.clipboard = "unnamedplus"
|
vim.o.clipboard = "unnamedplus" -- Sync Neovim with the system clipboard
|
||||||
vim.o.undofile = true
|
vim.o.undofile = true -- Enable persistent undo history between sessions
|
||||||
vim.o.undodir = "/home/narl/.cache/nvim-undodir"
|
vim.o.undodir = vim.fn.expand("~/.cache/nvim-undodir") -- Path to store undo history
|
||||||
|
|
||||||
vim.g.mapleader = ","
|
-- ============================================================================
|
||||||
|
-- 2. PLUGIN MANAGER (mini.deps)
|
||||||
-- Set up 'mini.deps' (customize to your liking)
|
-- ============================================================================
|
||||||
require("mini.deps").setup()
|
require("mini.deps").setup()
|
||||||
|
|
||||||
local add = MiniDeps.add
|
local add = MiniDeps.add
|
||||||
|
|
||||||
|
-- UI & Theming
|
||||||
|
add({ source = "catppuccin/nvim", name = "catppuccin" })
|
||||||
|
add({ source = "nvim-lualine/lualine.nvim" })
|
||||||
|
add({ source = "lewis6991/gitsigns.nvim" })
|
||||||
|
add({ source = "folke/which-key.nvim" })
|
||||||
|
|
||||||
|
-- Utility & Editing
|
||||||
|
add({ source = "akinsho/toggleterm.nvim" })
|
||||||
|
add({ source = "chomosuke/typst-preview.nvim" })
|
||||||
add({
|
add({
|
||||||
source = "lewis6991/gitsigns.nvim",
|
source = "MeanderingProgrammer/render-markdown.nvim",
|
||||||
})
|
depends = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.icons" },
|
||||||
add({
|
|
||||||
source = "chomosuke/typst-preview.nvim",
|
|
||||||
})
|
|
||||||
add({
|
|
||||||
source = "williamboman/mason.nvim",
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- LSP, Formatting & Linting
|
||||||
|
add({ source = "williamboman/mason.nvim" })
|
||||||
|
add({ source = "williamboman/mason-lspconfig.nvim" })
|
||||||
|
add({ source = "neovim/nvim-lspconfig", depends = { "williamboman/mason.nvim" } })
|
||||||
|
add({ source = "stevearc/conform.nvim" })
|
||||||
|
add({ source = "mfussenegger/nvim-lint" })
|
||||||
|
add({ source = "seblyng/roslyn.nvim" })
|
||||||
|
add({ source = "tris203/rzls.nvim" })
|
||||||
|
add({ source = "https://git.narl.io/nvrl/mould-rs", checkout = "main" })
|
||||||
|
|
||||||
|
-- Autocompletion
|
||||||
add({
|
add({
|
||||||
source = "stevearc/conform.nvim",
|
source = "Saghen/blink.cmp",
|
||||||
})
|
depends = { "rafamadriz/friendly-snippets" },
|
||||||
|
hooks = {
|
||||||
add({
|
post_install = function(ctx)
|
||||||
source = "williamboman/mason-lspconfig.nvim",
|
vim.cmd("!cd " .. ctx.path .. " && cargo build --release")
|
||||||
})
|
end,
|
||||||
|
post_checkout = function(ctx)
|
||||||
add({
|
vim.cmd("!cd " .. ctx.path .. " && cargo build --release")
|
||||||
source = "mfussenegger/nvim-lint",
|
end,
|
||||||
})
|
},
|
||||||
|
|
||||||
add({
|
|
||||||
source = "akinsho/toggleterm.nvim",
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Add to current session (install if absent)
|
|
||||||
add({
|
|
||||||
source = "neovim/nvim-lspconfig",
|
|
||||||
-- Supply dependencies near target plugin
|
|
||||||
depends = { "williamboman/mason.nvim" },
|
|
||||||
})
|
|
||||||
|
|
||||||
add({
|
|
||||||
source = "seblyng/roslyn.nvim",
|
|
||||||
})
|
|
||||||
|
|
||||||
add({
|
|
||||||
source = "tris203/rzls.nvim",
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Treesitter
|
||||||
add({
|
add({
|
||||||
source = "nvim-treesitter/nvim-treesitter",
|
source = "nvim-treesitter/nvim-treesitter",
|
||||||
-- Use 'master' while monitoring updates in 'main'
|
|
||||||
checkout = "master",
|
checkout = "master",
|
||||||
monitor = "main",
|
monitor = "main",
|
||||||
-- Perform action after every checkout
|
|
||||||
hooks = {
|
hooks = {
|
||||||
post_checkout = function()
|
post_checkout = function()
|
||||||
vim.cmd("TSUpdate")
|
vim.cmd("TSUpdate")
|
||||||
@@ -71,61 +76,99 @@ add({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
add({
|
-- ============================================================================
|
||||||
source = "https://git.narl.io/nvrl/mould-rs",
|
-- 3. MINI MODULES SETUP
|
||||||
checkout = "main",
|
-- ============================================================================
|
||||||
})
|
require("mini.extra").setup()
|
||||||
|
|
||||||
add({ source = "catppuccin/nvim", name = "catppuccin" })
|
|
||||||
add({ source = "folke/which-key.nvim" })
|
|
||||||
add({
|
|
||||||
source = 'Saghen/blink.cmp',
|
|
||||||
depends = { 'rafamadriz/friendly-snippets' },
|
|
||||||
-- Compile the Rust binary after downloading
|
|
||||||
hooks = {
|
|
||||||
post_install = function(ctx)
|
|
||||||
vim.cmd('!cd ' .. ctx.path .. ' && cargo build --release')
|
|
||||||
end,
|
|
||||||
post_checkout = function(ctx)
|
|
||||||
vim.cmd('!cd ' .. ctx.path .. ' && cargo build --release')
|
|
||||||
end
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
require("mini.files").setup({
|
|
||||||
mappings = {
|
|
||||||
show_help = "gh",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require("mini.icons").setup({ style = "ascii" })
|
require("mini.icons").setup({ style = "ascii" })
|
||||||
require("mini.pick").setup({})
|
require("mini.files").setup({ mappings = { show_help = "gh" } })
|
||||||
require("mini.snippets").setup({})
|
require("mini.pick").setup()
|
||||||
require("mini.notify").setup({})
|
require("mini.snippets").setup()
|
||||||
require("mini.statusline").setup({})
|
require("mini.notify").setup()
|
||||||
require("mini.tabline").setup({})
|
require("mini.tabline").setup()
|
||||||
require("mini.git").setup({})
|
require("mini.git").setup()
|
||||||
require("gitsigns").setup()
|
|
||||||
require("mini.indentscope").setup()
|
require("mini.indentscope").setup()
|
||||||
require("mini.pairs").setup()
|
require("mini.pairs").setup()
|
||||||
require("mini.surround").setup()
|
require("mini.surround").setup()
|
||||||
|
|
||||||
|
-- ============================================================================
|
||||||
|
-- 4. UI & THEMING
|
||||||
|
-- ============================================================================
|
||||||
|
|
||||||
|
-- Catppuccin Theme
|
||||||
|
require("catppuccin").setup({
|
||||||
|
flavour = "auto",
|
||||||
|
background = { light = "latte", dark = "mocha" },
|
||||||
|
transparent_background = false,
|
||||||
|
show_end_of_buffer = false,
|
||||||
|
integrations = {
|
||||||
|
cmp = true,
|
||||||
|
gitsigns = true,
|
||||||
|
nvimtree = true,
|
||||||
|
treesitter = true,
|
||||||
|
mini = { enabled = true },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
vim.cmd.colorscheme("catppuccin")
|
||||||
|
|
||||||
|
-- Git Signs
|
||||||
|
require("gitsigns").setup()
|
||||||
|
|
||||||
|
-- Which-Key (Keybind discoverability)
|
||||||
require("which-key").setup()
|
require("which-key").setup()
|
||||||
local imap_expr = function(lhs, rhs)
|
|
||||||
vim.keymap.set("i", lhs, rhs, { expr = true })
|
-- Lualine (Statusline)
|
||||||
end
|
local function active_lsp()
|
||||||
imap_expr("<Tab>", [[pumvisible() ? "\<C-n>" : "\<Tab>"]])
|
local clients = vim.lsp.get_clients({ bufnr = 0 })
|
||||||
imap_expr("<S-Tab>", [[pumvisible() ? "\<C-p>" : "\<S-Tab>"]])
|
if next(clients) == nil then
|
||||||
_G.cr_action = function()
|
return "No LSP"
|
||||||
-- If there is selected item in popup, accept it with <C-y>
|
|
||||||
if vim.fn.complete_info()["selected"] ~= -1 then
|
|
||||||
return "\25"
|
|
||||||
end
|
end
|
||||||
-- Fall back to plain `<CR>`. You might want to customize this
|
local client_names = {}
|
||||||
-- according to other plugins. For example if 'mini.pairs' is set up, replace
|
for _, client in ipairs(clients) do
|
||||||
-- next line with `return MiniPairs.cr()`
|
table.insert(client_names, client.name)
|
||||||
return "\r"
|
end
|
||||||
|
return "⚙ " .. table.concat(client_names, ", ")
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.keymap.set("i", "<CR>", "v:lua.cr_action()", { expr = true })
|
require("lualine").setup({
|
||||||
|
options = {
|
||||||
|
theme = require("catppuccin.utils.lualine")(),
|
||||||
|
component_separators = { left = "|", right = "|" },
|
||||||
|
section_separators = { left = "", right = "" },
|
||||||
|
globalstatus = true,
|
||||||
|
},
|
||||||
|
sections = {
|
||||||
|
lualine_a = { "mode" },
|
||||||
|
lualine_b = { "branch", "diff" },
|
||||||
|
lualine_c = { { "filename", path = 1 }, "diagnostics" },
|
||||||
|
lualine_x = { active_lsp },
|
||||||
|
lualine_y = { "encoding", "fileformat", "filetype" },
|
||||||
|
lualine_z = { "location", "progress" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Render Markdown
|
||||||
|
require("render-markdown").setup({
|
||||||
|
enabled = true,
|
||||||
|
anti_conceal = { enabled = true },
|
||||||
|
heading = {
|
||||||
|
icons = { "1. ", "2. ", "3. ", "4. ", "5. ", "6. " },
|
||||||
|
backgrounds = {
|
||||||
|
"RenderMarkdownH1Bg",
|
||||||
|
"RenderMarkdownH2Bg",
|
||||||
|
"RenderMarkdownH3Bg",
|
||||||
|
"RenderMarkdownH4Bg",
|
||||||
|
"RenderMarkdownH5Bg",
|
||||||
|
"RenderMarkdownH6Bg",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- ============================================================================
|
||||||
|
-- 5. TOOLS & INTEGRATIONS
|
||||||
|
-- ============================================================================
|
||||||
|
|
||||||
|
-- Toggleterm
|
||||||
require("toggleterm").setup({
|
require("toggleterm").setup({
|
||||||
size = function(term)
|
size = function(term)
|
||||||
if term.direction == "horizontal" then
|
if term.direction == "horizontal" then
|
||||||
@@ -140,58 +183,97 @@ require("toggleterm").setup({
|
|||||||
persist_size = true,
|
persist_size = true,
|
||||||
direction = "float",
|
direction = "float",
|
||||||
close_on_exit = true,
|
close_on_exit = true,
|
||||||
shell = vim.o.shell,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
require("nvim-treesitter.configs").setup({
|
-- Typst Preview
|
||||||
ensure_installed = { "lua", "rust", "toml", "c_sharp", "python", "typst" },
|
require("typst-preview").setup({
|
||||||
auto_install = true,
|
debug = false,
|
||||||
highlight = {
|
port = 0,
|
||||||
enable = true,
|
host = "127.0.0.1",
|
||||||
additional_vim_regex_highlighting = false,
|
invert_colors = "never",
|
||||||
},
|
follow_cursor = true,
|
||||||
ident = { enable = true },
|
dependencies_bin = {
|
||||||
rainbow = {
|
["tinymist"] = "/home/narl/.local/share/nvim/mason/bin/tinymist",
|
||||||
enable = true,
|
["websocat"] = "/usr/bin/websocat",
|
||||||
extended_mode = true,
|
|
||||||
max_file_lines = nil,
|
|
||||||
},
|
},
|
||||||
|
get_root = function(path_of_main_file)
|
||||||
|
local root = os.getenv("TYPST_ROOT")
|
||||||
|
if root then
|
||||||
|
return root
|
||||||
|
end
|
||||||
|
local main_dir = vim.fs.dirname(vim.fn.fnamemodify(path_of_main_file, ":p"))
|
||||||
|
local found = vim.fs.find({ "typst.toml", ".git" }, { path = main_dir, upward = true })
|
||||||
|
if #found > 0 then
|
||||||
|
return vim.fs.dirname(found[1])
|
||||||
|
end
|
||||||
|
return main_dir
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- ============================================================================
|
||||||
|
-- 6. TREESITTER, LSP, & AUTOCOMPLETION
|
||||||
|
-- ============================================================================
|
||||||
|
|
||||||
|
-- Treesitter
|
||||||
|
require("nvim-treesitter.configs").setup({
|
||||||
|
ensure_installed = { "lua", "rust", "toml", "c_sharp", "python", "typst", "markdown", "markdown_inline" },
|
||||||
|
auto_install = true,
|
||||||
|
highlight = { enable = true },
|
||||||
|
ident = { enable = true },
|
||||||
|
rainbow = { enable = true, extended_mode = true },
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Mason (Package Installer)
|
||||||
require("mason").setup({
|
require("mason").setup({
|
||||||
registries = {
|
registries = {
|
||||||
"github:mason-org/mason-registry",
|
"github:mason-org/mason-registry",
|
||||||
"github:Crashdummyy/mason-registry",
|
"github:Crashdummyy/mason-registry",
|
||||||
},
|
},
|
||||||
ui = {
|
|
||||||
icons = {
|
|
||||||
package_installed = "✓",
|
|
||||||
package_pending = "➜",
|
|
||||||
package_uninstalled = "✗",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
local capabilities = require('blink.cmp').get_lsp_capabilities()
|
-- Mason LSPConfig
|
||||||
|
|
||||||
require("mason-lspconfig").setup({
|
require("mason-lspconfig").setup({
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
"lua_ls", -- Lua
|
"lua_ls",
|
||||||
"gopls", -- Go
|
"gopls",
|
||||||
"clangd", -- C/C++
|
"clangd",
|
||||||
"html", -- HTML
|
"html",
|
||||||
"cssls", -- CSS
|
"cssls",
|
||||||
"jsonls", -- JSON
|
"jsonls",
|
||||||
"yamlls", -- YAML
|
"yamlls",
|
||||||
"bashls", -- Bash/Shell
|
"bashls",
|
||||||
"pyright", -- Python
|
"pyright",
|
||||||
"ts_ls", -- JS/TS/React
|
"ts_ls",
|
||||||
"rust_analyzer", -- Rust
|
"rust_analyzer",
|
||||||
"robotcode", -- Robot Framework
|
"robotcode",
|
||||||
"tinymist", -- Typst
|
"tinymist",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- List out the servers you are using
|
-- Blink.cmp (Autocompletion)
|
||||||
|
require("blink.cmp").setup({
|
||||||
|
keymap = {
|
||||||
|
preset = "none",
|
||||||
|
["<CR>"] = { "accept", "fallback" },
|
||||||
|
["<Tab>"] = { "select_next", "snippet_forward", "fallback" },
|
||||||
|
["<S-Tab>"] = { "select_prev", "snippet_backward", "fallback" },
|
||||||
|
["<Up>"] = { "select_prev", "fallback" },
|
||||||
|
["<Down>"] = { "select_next", "fallback" },
|
||||||
|
["<C-Space>"] = { "show", "show_documentation", "hide_documentation" },
|
||||||
|
},
|
||||||
|
completion = {
|
||||||
|
list = { selection = { preselect = false, auto_insert = true } },
|
||||||
|
},
|
||||||
|
appearance = {
|
||||||
|
use_nvim_cmp_as_default = true,
|
||||||
|
nerd_font_variant = "mono",
|
||||||
|
},
|
||||||
|
sources = { default = { "lsp", "path", "snippets", "buffer" } },
|
||||||
|
signature = { enabled = true },
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Global LSP Setup (Using Blink capabilities)
|
||||||
|
local capabilities = require("blink.cmp").get_lsp_capabilities()
|
||||||
local servers = {
|
local servers = {
|
||||||
"lua_ls",
|
"lua_ls",
|
||||||
"gopls",
|
"gopls",
|
||||||
@@ -206,174 +288,41 @@ local servers = {
|
|||||||
"rust_analyzer",
|
"rust_analyzer",
|
||||||
"robotcode",
|
"robotcode",
|
||||||
"tinymist",
|
"tinymist",
|
||||||
|
"marksman",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Configure capabilities for each server using Neovim's native API
|
|
||||||
for _, server in ipairs(servers) do
|
for _, server in ipairs(servers) do
|
||||||
vim.lsp.config(server, {
|
vim.lsp.config(server, { capabilities = capabilities })
|
||||||
capabilities = capabilities,
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Dedicated C# Setup
|
||||||
require("roslyn").setup({
|
require("roslyn").setup({
|
||||||
config = {
|
config = { handlers = require("rzls.roslyn_handlers") },
|
||||||
-- the rest of your Roslyn configuration
|
|
||||||
handlers = require("rzls.roslyn_handlers"),
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
require("catppuccin").setup({
|
-- ============================================================================
|
||||||
flavour = "auto", -- latte, frappe, macchiato, mocha
|
-- 7. DIAGNOSTICS, FORMATTING, & LINTING
|
||||||
background = { -- :h background
|
-- ============================================================================
|
||||||
light = "latte",
|
|
||||||
dark = "mocha",
|
|
||||||
},
|
|
||||||
transparent_background = false, -- disables setting the background color.
|
|
||||||
show_end_of_buffer = false, -- shows the '~' characters after the end of buffers
|
|
||||||
term_colors = false, -- sets terminal colors (e.g. `g:terminal_color_0`)
|
|
||||||
dim_inactive = {
|
|
||||||
enabled = false, -- dims the background color of inactive window
|
|
||||||
shade = "dark",
|
|
||||||
percentage = 0.15, -- percentage of the shade to apply to the inactive window
|
|
||||||
},
|
|
||||||
no_italic = false, -- Force no italic
|
|
||||||
no_bold = false, -- Force no bold
|
|
||||||
no_underline = false, -- Force no underline
|
|
||||||
styles = { -- Handles the styles of general hi groups (see `:h highlight-args`):
|
|
||||||
comments = { "italic" }, -- Change the style of comments
|
|
||||||
conditionals = { "italic" },
|
|
||||||
loops = {},
|
|
||||||
functions = {},
|
|
||||||
keywords = {},
|
|
||||||
strings = {},
|
|
||||||
variables = {},
|
|
||||||
numbers = {},
|
|
||||||
booleans = {},
|
|
||||||
properties = {},
|
|
||||||
types = {},
|
|
||||||
operators = {},
|
|
||||||
-- miscs = {}, -- Uncomment to turn off hard-coded styles
|
|
||||||
},
|
|
||||||
color_overrides = {},
|
|
||||||
custom_highlights = {},
|
|
||||||
default_integrations = true,
|
|
||||||
integrations = {
|
|
||||||
cmp = true,
|
|
||||||
gitsigns = true,
|
|
||||||
nvimtree = true,
|
|
||||||
treesitter = true,
|
|
||||||
notify = false,
|
|
||||||
mini = {
|
|
||||||
enabled = true,
|
|
||||||
indentscope_color = "",
|
|
||||||
},
|
|
||||||
-- For more plugins integrations please scroll down (https://github.com/catppuccin/nvim#integrations)
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
|
-- Diagnostics Configuration
|
||||||
local sign = function(opts)
|
local sign = function(opts)
|
||||||
vim.fn.sign_define(opts.name, {
|
vim.fn.sign_define(opts.name, { texthl = opts.name, text = opts.text, numhl = "" })
|
||||||
texthl = opts.name,
|
|
||||||
text = opts.text,
|
|
||||||
numhl = "",
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
sign({ name = "DiagnosticSignError", text = "" })
|
sign({ name = "DiagnosticSignError", text = "" })
|
||||||
sign({ name = "DiagnosticSignWarn", text = "" })
|
sign({ name = "DiagnosticSignWarn", text = "" })
|
||||||
sign({ name = "DiagnosticSignHint", text = "" })
|
sign({ name = "DiagnosticSignHint", text = "" })
|
||||||
sign({ name = "DiagnosticSignInfo", text = "" })
|
sign({ name = "DiagnosticSignInfo", text = "" })
|
||||||
|
|
||||||
vim.opt.completeopt = { "menuone", "noselect", "noinsert" }
|
|
||||||
vim.opt.shortmess = vim.opt.shortmess + { c = true }
|
|
||||||
vim.api.nvim_set_option("updatetime", 300)
|
|
||||||
|
|
||||||
vim.cmd([[
|
|
||||||
set signcolumn=yes
|
|
||||||
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
|
|
||||||
]])
|
|
||||||
|
|
||||||
vim.diagnostic.config({
|
vim.diagnostic.config({
|
||||||
virtual_text = false,
|
virtual_text = false,
|
||||||
signs = true,
|
signs = true,
|
||||||
update_in_insert = true,
|
update_in_insert = true,
|
||||||
underline = true,
|
underline = true,
|
||||||
severity_sort = false,
|
severity_sort = false,
|
||||||
float = {
|
float = { border = "rounded", source = "always", header = "", prefix = "" },
|
||||||
border = "rounded",
|
|
||||||
source = "always",
|
|
||||||
header = "",
|
|
||||||
prefix = "",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.cmd.colorscheme("catppuccin")
|
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>w", "<cmd>write<cr>", { desc = "Save file" })
|
|
||||||
vim.keymap.set("n", "<leader>q", "<cmd>quitall<cr>", { desc = "Exit vim" })
|
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>e", "<cmd>lua MiniFiles.open()<cr>", { desc = "File explorer" })
|
|
||||||
vim.keymap.set("n", "<leader><space>", "<cmd>Pick buffers<cr>", { desc = "Search open files" })
|
|
||||||
vim.keymap.set("n", "<leader>ff", "<cmd>Pick files<cr>", { desc = "Search all files" })
|
|
||||||
vim.keymap.set("n", "<leader>fh", "<cmd>Pick help<cr>", { desc = "Search help tags" })
|
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>h", "<cmd>wincmd h<cr>")
|
|
||||||
vim.keymap.set("n", "<leader>l", "<cmd>wincmd l<cr>")
|
|
||||||
vim.keymap.set("n", "<leader>j", "<cmd>wincmd j<cr>")
|
|
||||||
vim.keymap.set("n", "<leader>k", "<cmd>wincmd k<cr>")
|
|
||||||
|
|
||||||
require("typst-preview").setup({
|
|
||||||
debug = false,
|
|
||||||
open_cmd = nil,
|
|
||||||
port = 0,
|
|
||||||
host = "127.0.0.1",
|
|
||||||
invert_colors = "never",
|
|
||||||
follow_cursor = true,
|
|
||||||
dependencies_bin = {
|
|
||||||
["tinymist"] = "/home/narl/.local/share/nvim/mason/bin/tinymist",
|
|
||||||
["websocat"] = "/usr/bin/websocat",
|
|
||||||
},
|
|
||||||
extra_args = nil,
|
|
||||||
get_root = function(path_of_main_file)
|
|
||||||
local root = os.getenv("TYPST_ROOT")
|
|
||||||
if root then
|
|
||||||
return root
|
|
||||||
end
|
|
||||||
|
|
||||||
local main_dir = vim.fs.dirname(vim.fn.fnamemodify(path_of_main_file, ":p"))
|
|
||||||
local found = vim.fs.find({ "typst.toml", ".git" }, { path = main_dir, upward = true })
|
|
||||||
if #found > 0 then
|
|
||||||
return vim.fs.dirname(found[1])
|
|
||||||
end
|
|
||||||
|
|
||||||
return main_dir
|
|
||||||
end,
|
|
||||||
get_main_file = function(path_of_buffer)
|
|
||||||
return path_of_buffer
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
require('blink.cmp').setup({
|
|
||||||
-- 'default' maps match standard nvim-cmp behavior (<C-space>, <C-n>, <C-p>, <CR>)
|
|
||||||
-- 'super-tab' uses your Tab key for everything
|
|
||||||
keymap = { preset = 'default' },
|
|
||||||
|
|
||||||
appearance = {
|
|
||||||
-- Sets the fallback highlight groups to nvim-cmp's highlight groups
|
|
||||||
use_nvim_cmp_as_default = true,
|
|
||||||
-- Set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
|
|
||||||
nerd_font_variant = 'mono'
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Default list of enabled providers
|
|
||||||
sources = {
|
|
||||||
default = { 'lsp', 'path', 'snippets', 'buffer' },
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Enable displaying function signatures as you type parameters
|
|
||||||
signature = { enabled = true }
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Formatting (Conform)
|
||||||
require("conform").setup({
|
require("conform").setup({
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
cs = { "csharpier" },
|
cs = { "csharpier" },
|
||||||
@@ -395,52 +344,92 @@ require("conform").setup({
|
|||||||
typescriptreact = { "prettier" },
|
typescriptreact = { "prettier" },
|
||||||
typst = { "typstyle" },
|
typst = { "typstyle" },
|
||||||
xml = { "xmlformatter" },
|
xml = { "xmlformatter" },
|
||||||
|
markdown = { "prettier", "injected" },
|
||||||
},
|
},
|
||||||
|
|
||||||
format_on_save = function(bufnr)
|
format_on_save = function(bufnr)
|
||||||
if vim.bo[bufnr].filetype ~= "rust" then
|
if vim.bo[bufnr].filetype ~= "rust" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
return { timeout_ms = 3000, lsp_fallback = true }
|
||||||
return {
|
|
||||||
timeout_ms = 3000,
|
|
||||||
lsp_fallback = true,
|
|
||||||
}
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>f", function()
|
-- Linting (Nvim-Lint)
|
||||||
require("conform").format({
|
|
||||||
lsp_fallback = true,
|
|
||||||
async = false,
|
|
||||||
timeout_ms = 3000,
|
|
||||||
})
|
|
||||||
end, { desc = "Format file or range" })
|
|
||||||
|
|
||||||
-- Nvim-Lint Configuration
|
|
||||||
require("lint").linters_by_ft = {
|
require("lint").linters_by_ft = {
|
||||||
python = { "flake8" },
|
python = { "flake8" },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- ============================================================================
|
||||||
|
-- 8. AUTOCOMMANDS
|
||||||
|
-- ============================================================================
|
||||||
|
|
||||||
|
-- Show floating diagnostic on cursor hold
|
||||||
|
vim.cmd([[
|
||||||
|
set signcolumn=yes
|
||||||
|
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
|
||||||
|
]])
|
||||||
|
|
||||||
-- Trigger linting on file save
|
-- Trigger linting on file save
|
||||||
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||||
callback = function()
|
callback = function()
|
||||||
require("lint").try_lint()
|
require("lint").try_lint()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
vim.api.nvim_create_autocmd('LspAttach', {
|
|
||||||
callback = function(event)
|
-- Markdown specific settings
|
||||||
local opts = { buffer = event.buf }
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
pattern = "markdown",
|
||||||
-- Press 'K' to show hover documentation
|
callback = function()
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
vim.opt_local.wrap = true
|
||||||
-- Press 'gd' to jump to a function/variable definition
|
vim.keymap.set("n", "j", "gj", { buffer = true, desc = "Move down visual line" })
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
vim.keymap.set("n", "k", "gk", { buffer = true, desc = "Move up visual line" })
|
||||||
-- Press '<leader>rn' to rename a variable across the whole project
|
end,
|
||||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
|
||||||
-- Press '<leader>ca' to see code actions (like quick fixes)
|
|
||||||
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, opts)
|
|
||||||
-- Press 'gr' to find all references of the word under your cursor
|
|
||||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
|
||||||
end,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Dynamic LSP Keymaps (Loaded only when LSP attaches to a buffer)
|
||||||
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
|
callback = function(event)
|
||||||
|
local opts = { buffer = event.buf }
|
||||||
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||||
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||||
|
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||||
|
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||||
|
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- ============================================================================
|
||||||
|
-- 9. GLOBAL KEYMAPS
|
||||||
|
-- ============================================================================
|
||||||
|
|
||||||
|
-- General Operations
|
||||||
|
vim.keymap.set("n", "<leader>w", "<cmd>write<cr>", { desc = "Save file" })
|
||||||
|
vim.keymap.set("n", "<leader>q", "<cmd>quitall<cr>", { desc = "Exit Neovim" })
|
||||||
|
|
||||||
|
-- Window Navigation
|
||||||
|
vim.keymap.set("n", "<leader>h", "<cmd>wincmd h<cr>", { desc = "Move to left split" })
|
||||||
|
vim.keymap.set("n", "<leader>l", "<cmd>wincmd l<cr>", { desc = "Move to right split" })
|
||||||
|
vim.keymap.set("n", "<leader>j", "<cmd>wincmd j<cr>", { desc = "Move to lower split" })
|
||||||
|
vim.keymap.set("n", "<leader>k", "<cmd>wincmd k<cr>", { desc = "Move to upper split" })
|
||||||
|
|
||||||
|
-- Search & Navigation (Mini Pick & Files)
|
||||||
|
vim.keymap.set("n", "<leader>e", "<cmd>lua MiniFiles.open()<cr>", { desc = "Open File Explorer" })
|
||||||
|
vim.keymap.set("n", "<leader><space>", "<cmd>Pick buffers<cr>", { desc = "Search open buffers" })
|
||||||
|
vim.keymap.set("n", "<leader>ff", "<cmd>Pick files<cr>", { desc = "Search all files" })
|
||||||
|
vim.keymap.set("n", "<leader>fh", "<cmd>Pick help<cr>", { desc = "Search help tags" })
|
||||||
|
|
||||||
|
-- Formatting Trigger
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>f", function()
|
||||||
|
require("conform").format({ lsp_fallback = true, async = false, timeout_ms = 3000 })
|
||||||
|
end, { desc = "Format file or range" })
|
||||||
|
|
||||||
|
-- Diagnostics Navigation
|
||||||
|
vim.keymap.set("n", "<leader>fd", "<cmd>Pick diagnostic<cr>", { desc = "Search all diagnostics" })
|
||||||
|
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Next diagnostic" })
|
||||||
|
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Previous diagnostic" })
|
||||||
|
vim.keymap.set("n", "]e", function()
|
||||||
|
vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.ERROR })
|
||||||
|
end, { desc = "Next error" })
|
||||||
|
vim.keymap.set("n", "[e", function()
|
||||||
|
vim.diagnostic.goto_prev({ severity = vim.diagnostic.severity.ERROR })
|
||||||
|
end, { desc = "Previous error" })
|
||||||
|
|||||||
Reference in New Issue
Block a user