diff options
Diffstat (limited to '.config/nvim/lua')
-rw-r--r-- | .config/nvim/lua/user/beautiful.lua | 8 | ||||
-rw-r--r-- | .config/nvim/lua/user/lsp/bash.lua | 1 | ||||
-rw-r--r-- | .config/nvim/lua/user/lsp/common.lua | 81 | ||||
-rw-r--r-- | .config/nvim/lua/user/lsp/cxx.lua | 1 | ||||
-rw-r--r-- | .config/nvim/lua/user/lsp/haskell.lua | 1 | ||||
-rw-r--r-- | .config/nvim/lua/user/lsp/lua.lua | 1 | ||||
-rw-r--r-- | .config/nvim/lua/user/lsp/python.lua | 1 | ||||
-rw-r--r-- | .config/nvim/lua/user/lsp/rust.lua | 26 | ||||
-rw-r--r-- | .config/nvim/lua/user/lspinit.lua | 10 | ||||
-rw-r--r-- | .config/nvim/lua/user/options.lua | 7 | ||||
-rw-r--r-- | .config/nvim/lua/user/plugins.lua | 44 | ||||
-rw-r--r-- | .config/nvim/lua/user/remaps.lua | 6 |
12 files changed, 172 insertions, 15 deletions
diff --git a/.config/nvim/lua/user/beautiful.lua b/.config/nvim/lua/user/beautiful.lua index 17b7ed5..6af5f98 100644 --- a/.config/nvim/lua/user/beautiful.lua +++ b/.config/nvim/lua/user/beautiful.lua @@ -1,6 +1,12 @@ -- this file contains configuration for colorschemes e.t.c +vim.cmd("colorscheme default") + local colorscheme = "habamax" -- local colorscheme = "evening" -vim.cmd("colo " .. colorscheme) +local status, _retval = pcall(vim.cmd, "colo " .. colorscheme) +if not status then + vim.notify("Error: colorscheme \"" .. colorscheme .. "\" not found!") + return -- what the fuck lua where does this return lmao +end diff --git a/.config/nvim/lua/user/lsp/bash.lua b/.config/nvim/lua/user/lsp/bash.lua new file mode 100644 index 0000000..5cd4a2e --- /dev/null +++ b/.config/nvim/lua/user/lsp/bash.lua @@ -0,0 +1 @@ +lsp = require 'lspconfig' diff --git a/.config/nvim/lua/user/lsp/common.lua b/.config/nvim/lua/user/lsp/common.lua new file mode 100644 index 0000000..032cb7f --- /dev/null +++ b/.config/nvim/lua/user/lsp/common.lua @@ -0,0 +1,81 @@ +-- this file contains setup for snippets and common LSP options + +local cmp_status, cmp = pcall(require, 'cmp') +-- vim.api.nvim_echo({{"Hello!", "Normal"}}, true, {}) +if not cmp_status then + vim.api.nvim_err_writeln(string.format("shit! error status: %s", cmp_status)) + return +end +luasnip = require 'luasnip' +luasnip.setup() + +local expnoresilent = {expr = true, noremap = true, silent = true} +local noresilent = {noremap = true, silent = true} + +-- stolen from https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance +local kind_icons = { + Text = "", Method = "", + Function = "", Constructor = "", + Field = "", Variable = "", + Class = "", Interface = "", + Module = "", Property = "", + Unit = "", Value = "", + Enum = "", Keyword = "", + Snippet = "", Color = "", + File = "", Reference = "", + Folder = "", EnumMember = "", + Constant = "", Struct = "", + Event = "", Operator = "", + TypeParameter = "", +} + +-- from https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip +local stolen_function = function() -- to check whether there are words before cursor + unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil +end + +-- TODO: Finish +cmp.setup { + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) -- for vsnip (i left it) + luasnip.lsp_expand(args.body) -- for luasnip cause i like it more + end, + }, + -- NOTE: ordering or this table affects completions ordering + sources = { -- TODO: Add keyword_length to some of them ?????? + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'buffer' }, + { name = 'path' }, + { name = 'calc' }, + { name = 'nvim_lua' }, + { name = 'nvim_lsp_signature_help' }, + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + -- the function is also half-stolen + format = function(entry, vim_item) + vim_item.kind = string.format("%s · |%s|", kind_icons[vim_item.kind], vim_item.kind) + vim_item.menu = ({ + buffer = "[Buffer]", + nvim_lsp = "[Lsp]", + vsnip = "[Vsnip]", + luasnip = "[Luasnip]", + path = "[Path]", + nvim_lua = "[Lua]", + calc = "[(x)dx]", + nvim_lsp_signature_help = "[Lsp-help]", + })[entry.source.name] + return vim_item + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + experimental = { ghost_text = true }, +} + diff --git a/.config/nvim/lua/user/lsp/cxx.lua b/.config/nvim/lua/user/lsp/cxx.lua new file mode 100644 index 0000000..5cd4a2e --- /dev/null +++ b/.config/nvim/lua/user/lsp/cxx.lua @@ -0,0 +1 @@ +lsp = require 'lspconfig' diff --git a/.config/nvim/lua/user/lsp/haskell.lua b/.config/nvim/lua/user/lsp/haskell.lua new file mode 100644 index 0000000..5cd4a2e --- /dev/null +++ b/.config/nvim/lua/user/lsp/haskell.lua @@ -0,0 +1 @@ +lsp = require 'lspconfig' diff --git a/.config/nvim/lua/user/lsp/lua.lua b/.config/nvim/lua/user/lsp/lua.lua new file mode 100644 index 0000000..5cd4a2e --- /dev/null +++ b/.config/nvim/lua/user/lsp/lua.lua @@ -0,0 +1 @@ +lsp = require 'lspconfig' diff --git a/.config/nvim/lua/user/lsp/python.lua b/.config/nvim/lua/user/lsp/python.lua new file mode 100644 index 0000000..5cd4a2e --- /dev/null +++ b/.config/nvim/lua/user/lsp/python.lua @@ -0,0 +1 @@ +lsp = require 'lspconfig' diff --git a/.config/nvim/lua/user/lsp/rust.lua b/.config/nvim/lua/user/lsp/rust.lua new file mode 100644 index 0000000..cfc5c2a --- /dev/null +++ b/.config/nvim/lua/user/lsp/rust.lua @@ -0,0 +1,26 @@ +lsp = require 'lspconfig' + +vim.cmd [[ + autocmd FileType rust highlight link rustLifetime SpecialComment +]] + +vim.cmd [[ + autocmd FileType rust setlocal inccommand=nosplit +]] + +lsp.rust_analyzer.setup{ + cmd = {"rust-analyzer"}, + filetypes = {"rust", "rs"}, + root_dir = lsp.util.root_pattern("Cargo.toml"), + -- fucking magic + capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), + settings = { + ["rust-analyzer"] = { + disgnostics = { enable = false }, + inlayHints = { typeHints = true }, + }, + }, +} + + + diff --git a/.config/nvim/lua/user/lspinit.lua b/.config/nvim/lua/user/lspinit.lua new file mode 100644 index 0000000..38b8eb0 --- /dev/null +++ b/.config/nvim/lua/user/lspinit.lua @@ -0,0 +1,10 @@ +require 'user.lsp.common' +require 'user.lsp.haskell' +require 'user.lsp.python' +require 'user.lsp.bash' +require 'user.lsp.rust' +require 'user.lsp.cxx' +require 'user.lsp.lua' + +-- lsp = require 'lspconfig' + diff --git a/.config/nvim/lua/user/options.lua b/.config/nvim/lua/user/options.lua index a8e58bc..44c3599 100644 --- a/.config/nvim/lua/user/options.lua +++ b/.config/nvim/lua/user/options.lua @@ -16,8 +16,9 @@ local options = { shiftwidth = 8, smartindent = true, swapfile = false, - timeoutlen = 1000, --ms - updatetime = 300, + timeoutlen = 1000, --ms + termguicolors = true, + updatetime = 300, --ms writebackup = false, expandtab = false, -- !!!!!!!!! cursorline = false, @@ -26,6 +27,8 @@ local options = { -- splitting splitbelow = true, splitright = true, + -- autocompletion + completeopt = { 'menuone', 'noselect', 'noinsert' } } for key, val in pairs(options) do diff --git a/.config/nvim/lua/user/plugins.lua b/.config/nvim/lua/user/plugins.lua index ee7dea7..2e52200 100644 --- a/.config/nvim/lua/user/plugins.lua +++ b/.config/nvim/lua/user/plugins.lua @@ -1,17 +1,41 @@ -- this file contains plugin settings as well as initialization of lazy.nvim - -- plugins to be installed plugins = { - "folke/lazy.nvim", -- plugin manager - "nvim-lua/popup.nvim", -- some functions for other plugins - "nvim-lua/plenary.nvim", -- some functions for other plugins - "folke/which-key.nvim", -- pretty self-descriptive name - "rafi/awesome-vim-colorschemes", -- same here - "tpope/vim-commentary", -- gc & gcc for commenting - "tpope/vim-surround", -- replace quotes e.t.c - "nvim-treesitter/nvim-treesitter", -- folding code, advanced syntax highlighting & sitting on a tree - "preservim/nerdtree", -- file explorer + { "folke/lazy.nvim" }, -- plugin manager + -- "williamboman/mason.nvim", -- plugin manager for LSP + -- "williamboman/mason-lspconfig.nvim", -- mason add-ons for lspconfig + + { "nvim-lua/popup.nvim" }, -- some functions for other plugins + { "nvim-lua/plenary.nvim" }, -- some functions for other plugins + { "folke/which-key.nvim" }, -- pretty self-descriptive name + + { "rafi/awesome-vim-colorschemes" }, -- colorschemes + { "lunarvim/colorschemes" }, -- colorschemes + { "folke/tokyonight.nvim" }, -- colorschemes + + { "tpope/vim-commentary" }, -- gc & gcc for commenting + { "tpope/vim-surround" }, -- replace quotes e.t.c + { "preservim/nerdtree" }, -- file explorer + + { "nvim-treesitter/nvim-treesitter" }, -- folding code, advanced syntax highlighting & sitting on a tree + { "neovim/nvim-lspconfig" }, -- LSP configuration + + -- { "hrsh7th/vim-vsnip" }, -- snippet engine + { "L3MON4D3/LuaSnip" }, -- better snippet engine + { "saadparwaiz1/cmp_luasnip" }, -- for luasnip + { "rafamadriz/friendly-snippets" }, -- predefined snippets + + -- Autocompletion framework + { "hrsh7th/nvim-cmp" }, -- the framework + { "hrsh7th/cmp-nvim-lua" }, -- lua config + { "hrsh7th/cmp-nvim-lsp-signature-help" }, -- ?????????? a monster + { "hrsh7th/cmp-nvim-lsp" }, -- LSP completion + { "hrsh7th/cmp-path" }, -- /mnt/D/media/audio_sync/term_download_mp3/HELLO_I_AM_EMU_OTORI.mp3 + { "hrsh7th/cmp-buffer" }, -- current buffer + { "hrsh7th/cmp-cmdline" }, -- command line tools + { "Saecki/crates.nvim" }, -- rust packages from crates.io + } -- options for lazy diff --git a/.config/nvim/lua/user/remaps.lua b/.config/nvim/lua/user/remaps.lua index a047392..e5a465c 100644 --- a/.config/nvim/lua/user/remaps.lua +++ b/.config/nvim/lua/user/remaps.lua @@ -14,6 +14,8 @@ map("n", "j", "<Up>", opt) map("n", "k", "<Down>", opt) map("n", "dj", "d<Up>", opt) map("n", "dk", "d<Down>", opt) +map("v", "j", "<Up>", opt) +map("v", "k", "<Down>", opt) -- window navigation map("n", "<C-j>", "<C-w>k", opt) -- SWITCHED K AND J @@ -30,9 +32,9 @@ map("i", "<C-h>", "<Left>", opt) map("i", "<C-j>", "<Up>", opt) -- SWITCHED K AND J map("i", "<C-k>", "<Down>", opt) -- SWITCHED K AND J map("i", "<C-l>", "<Right>", opt) -map("i", "<C-w>", "<C-Right>", opt) +map("i", "<C-w>", "<Esc>wi", opt) map("i", "<C-W>", "<Esc>Wi", opt) -map("i", "<C-b>", "<C-Left>", opt) +map("i", "<C-b>", "<Esc>bi", opt) map("i", "<C-B>", "<Esc>Bi", opt) -- Terminal mode |