commit fd3267ca2166ea1607f7ee863bec0d253a104d93 Author: gasaichandesu Date: Mon Jun 1 12:46:46 2026 +0400 Initial LSP setup with formatting and autocompletion diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/.luarc.json @@ -0,0 +1 @@ +{} diff --git a/after/lsp/lua_ls.lua b/after/lsp/lua_ls.lua new file mode 100644 index 0000000..cfcb41f --- /dev/null +++ b/after/lsp/lua_ls.lua @@ -0,0 +1,14 @@ +---@type vim.lsp.Config +local settings = { + ---@type lspconfig.settings.lua_ls + settings = { + Lua = { + runtime = { + version = 'LuaJIT', + }, + workspace = { checkThirdParty = false, library = vim.list_extend({ vim.fn.expand('$VIMRUNTIME') }, vim.api.nvim_get_runtime_file('lua', true)) }, + }, + }, +} + +return settings diff --git a/after/plugin/autopairs.lua b/after/plugin/autopairs.lua new file mode 100644 index 0000000..655d504 --- /dev/null +++ b/after/plugin/autopairs.lua @@ -0,0 +1,3 @@ +local autopairs = require("nvim-autopairs") + +autopairs.setup({}) diff --git a/after/plugin/telescope.lua b/after/plugin/telescope.lua new file mode 100644 index 0000000..f98bc65 --- /dev/null +++ b/after/plugin/telescope.lua @@ -0,0 +1,23 @@ +local telescope = require("telescope") +local builtin = require("telescope.builtin") +local utils = require("utils") + +local options = { + defaults = { + path_display = { "truncate" }, + sorting_strategy = "ascending", + layout_config = { + prompt_position = "top", + }, + }, +} + +telescope.setup(options) + +utils.nmap("ff", builtin.find_files, "Find Files") +utils.nmap("fg", builtin.live_grep, "Live Grep") + +utils.nmap("fr", builtin.lsp_references, "LSP References") +utils.nmap("fi", builtin.lsp_implementations, "LSP Implementations") +utils.nmap("fs", builtin.lsp_document_symbols, "LSP Document Symbols") +utils.nmap("fS", builtin.lsp_dynamic_workspace_symbols, "LSP Workspace Symbols") diff --git a/after/plugin/wow.lua b/after/plugin/wow.lua new file mode 100644 index 0000000..436a5f3 --- /dev/null +++ b/after/plugin/wow.lua @@ -0,0 +1,3 @@ +local warcraft_api = require("warcraft-api") + +warcraft_api.setup({}) diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..b813abc --- /dev/null +++ b/init.lua @@ -0,0 +1,58 @@ +vim.g.mapleader = " " +vim.g.localmapleader = " " + +require("plugins") +require("lsp") +require("completion") +require("formatting") +require("colorscheme") + +local opt = vim.opt + +-- Line numbers +opt.number = true +opt.relativenumber = true + +-- Indentation +opt.expandtab = true +opt.tabstop = 4 +opt.shiftwidth = 4 +opt.softtabstop = 4 +opt.smartindent = true +opt.breakindent = true + +-- Search +opt.ignorecase = true +opt.smartcase = true +opt.hlsearch = false +opt.incsearch = true + +-- Appearance +opt.termguicolors = true +opt.signcolumn = "yes" +opt.cursorline = true +opt.scrolloff = 8 +opt.sidescrolloff = 8 +opt.wrap = false +opt.colorcolumn = "120" + +vim.cmd("colorscheme rose-pine") + +-- Splits +opt.splitright = true +opt.splitbelow = true + +-- Files +opt.undofile = true +opt.swapfile = false +opt.backup = false +opt.updatetime = 250 + +-- Clipboard +opt.clipboard = "unnamedplus" + +-- Misc +opt.mouse = "a" +opt.showmode = false +opt.isfname:append("@-@") +opt.exrc = true diff --git a/lua/colorscheme.lua b/lua/colorscheme.lua new file mode 100644 index 0000000..b321d62 --- /dev/null +++ b/lua/colorscheme.lua @@ -0,0 +1 @@ +require("rose-pine").setup() diff --git a/lua/completion.lua b/lua/completion.lua new file mode 100644 index 0000000..154b24b --- /dev/null +++ b/lua/completion.lua @@ -0,0 +1,14 @@ +---@type blink.cmp.API +local cmp = require("blink.cmp") + +cmp.build():pwait() + +---@type blink.cmp.Config +local cmp_options = { + keymap = { preset = "default" }, + completion = { menu = { auto_show = true }, documentation = { auto_show = true } }, + sources = { default = { "lsp", "path", "snippets", "buffer" } }, + fuzzy = { implementation = "rust" }, +} + +cmp.setup(cmp_options) diff --git a/lua/formatting.lua b/lua/formatting.lua new file mode 100644 index 0000000..58d29dc --- /dev/null +++ b/lua/formatting.lua @@ -0,0 +1,21 @@ +local conform = require("conform") + +---@type conform.setupOpts +local options = { + formatters_by_ft = { + lua = { "stylua" }, + }, + format_on_save = { + timeout_ms = 500, + lsp_format = "fallback", + }, +} + +vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*", + callback = function(args) + conform.format({ bufnr = args.buf }) + end, +}) + +conform.setup(options) diff --git a/lua/lsp.lua b/lua/lsp.lua new file mode 100644 index 0000000..6fbde5c --- /dev/null +++ b/lua/lsp.lua @@ -0,0 +1,7 @@ +require("mason").setup({}) +require("mason-lspconfig").setup({ + ensure_installed = { + "lua_ls", + "stylua", + }, +}) diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..d26c159 --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,34 @@ +vim.pack.add({ + -- Common dependencies + { src = "https://github.com/nvim-lua/plenary.nvim" }, + + -- Automatically install language servers + { src = "https://github.com/mason-org/mason.nvim" }, + + -- Predefined configs for language servers + { src = "https://github.com/neovim/nvim-lspconfig" }, + + -- Automatically enable installed language servers + { src = "https://github.com/mason-org/mason-lspconfig.nvim" }, + + -- All-in-one completions engine + { src = "https://github.com/saghen/blink.lib" }, + { src = "https://github.com/saghen/blink.cmp" }, + + -- Code formatting + { src = "https://github.com/stevearc/conform.nvim" }, + + -- Appearance + { src = "https://github.com/rose-pine/neovim", name = "rose-pine" }, + { src = "https://github.com/nvim-tree/nvim-web-devicons" }, + + -- Fuzzy finder + { src = "https://github.com/nvim-telescope/telescope.nvim" }, + { src = "https://github.com/nvim-telescope/telescope-fzf-native.nvim" }, + + -- Miscellaneous + { src = "https://github.com/windwp/nvim-autopairs" }, + + -- WoW Addon API + { src = "https://github.com/Tyrannican/warcraft-api.nvim" }, +}) diff --git a/lua/utils.lua b/lua/utils.lua new file mode 100644 index 0000000..0d1697b --- /dev/null +++ b/lua/utils.lua @@ -0,0 +1,28 @@ +local M = {} + +function M.map(mode, keys, func, desc, opts) + vim.keymap.set( + mode, + keys, + func, + vim.tbl_extend("force", { + desc = desc, + noremap = true, + silent = true, + }, opts or {}) + ) +end + +function M.nmap(keys, func, desc, opts) + M.map("n", keys, func, desc, opts) +end + +function M.vmap(keys, func, desc, opts) + M.map("v", keys, func, desc, opts) +end + +function M.imap(keys, func, desc, opts) + M.map("i", keys, func, desc, opts) +end + +return M diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json new file mode 100644 index 0000000..b6c87f8 --- /dev/null +++ b/nvim-pack-lock.json @@ -0,0 +1,56 @@ +{ + "plugins": { + "blink.cmp": { + "rev": "5ee69ea52492fa038b3a1cd8de55edffe205c77d", + "src": "https://github.com/saghen/blink.cmp" + }, + "blink.lib": { + "rev": "2cb62890cee636fe46722d03b7b2331e54fb3755", + "src": "https://github.com/saghen/blink.lib" + }, + "conform.nvim": { + "rev": "619363c30309d29ffa631e67c8183f2a72caa373", + "src": "https://github.com/stevearc/conform.nvim" + }, + "mason-lspconfig.nvim": { + "rev": "0a695750d747db1e7e70bcf0267ef8951c95fc83", + "src": "https://github.com/mason-org/mason-lspconfig.nvim" + }, + "mason.nvim": { + "rev": "16ba83bfc8a25f52bb545134f5bee082b195c460", + "src": "https://github.com/mason-org/mason.nvim" + }, + "nvim-autopairs": { + "rev": "7b9923abad60b903ece7c52940e1321d39eccc79", + "src": "https://github.com/windwp/nvim-autopairs" + }, + "nvim-lspconfig": { + "rev": "9573948c38bfabeec353ae7dd7d3ffec4c506a6b", + "src": "https://github.com/neovim/nvim-lspconfig" + }, + "nvim-web-devicons": { + "rev": "dfbfaa967a6f7ec50789bead7ef87e336c1fa63c", + "src": "https://github.com/nvim-tree/nvim-web-devicons" + }, + "plenary.nvim": { + "rev": "74b06c6c75e4eeb3108ec01852001636d85a932b", + "src": "https://github.com/nvim-lua/plenary.nvim" + }, + "rose-pine": { + "rev": "ff483051a47e27d84bdef47703538df1ed9f4a47", + "src": "https://github.com/rose-pine/neovim" + }, + "telescope-fzf-native.nvim": { + "rev": "b25b749b9db64d375d782094e2b9dce53ad53a40", + "src": "https://github.com/nvim-telescope/telescope-fzf-native.nvim" + }, + "telescope.nvim": { + "rev": "7d324792b7943e4aa16ad007212e6acc6f9fe335", + "src": "https://github.com/nvim-telescope/telescope.nvim" + }, + "warcraft-api.nvim": { + "rev": "c016bc54ed62bca5058cc3bd7553e429dd8caf37", + "src": "https://github.com/Tyrannican/warcraft-api.nvim" + } + } +}