diff options
Diffstat (limited to '.config/nvim/lua/user')
-rw-r--r-- | .config/nvim/lua/user/lsp/common.lua | 36 | ||||
-rw-r--r-- | .config/nvim/lua/user/lsp/rust.lua | 47 | ||||
-rw-r--r-- | .config/nvim/lua/user/lspinit.lua | 1 | ||||
-rw-r--r-- | .config/nvim/lua/user/plugins.lua | 14 | ||||
-rw-r--r-- | .config/nvim/lua/user/snippets.lua | 18 | ||||
-rw-r--r-- | .config/nvim/lua/user/treesitter.lua | 20 |
6 files changed, 110 insertions, 26 deletions
diff --git a/.config/nvim/lua/user/lsp/common.lua b/.config/nvim/lua/user/lsp/common.lua index 7873752..1b1920c 100644 --- a/.config/nvim/lua/user/lsp/common.lua +++ b/.config/nvim/lua/user/lsp/common.lua @@ -1,5 +1,32 @@ -- this file contains setup for snippets and common LSP options +-- nvim diagnostics setup + +local define_sign = function(options) + vim.fn.sign_define(options.name, { texthl = options.name, text = options.textm, numhl = '' }) +end + +define_sign({name = "DiagnosticSignError", text = ''}) +define_sign({name = "DiagnosticSignWarn", text = ''}) +define_sign({name = "DiagnosticSignHint", text = ''}) +define_sign({name = "DiagnosticSignInfo", text = ''}) + +vim.diagnostic.config{ + virtual_text = true, + signs = true, + update_in_insert = false, + underline = true, + severity_sort = true, + float = { + source = 'always', + }, +} + +vim.cmd[[ +set signcolumn=yes +autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) +]] + -- WHY THE FUCK DID THE PROTECTED CALL SOLVE THE ISSUE UGH local cmp_status, cmp = pcall(require, 'cmp') if not cmp_status then @@ -8,7 +35,8 @@ if not cmp_status then end autopairs_cmp = require 'nvim-autopairs.completion.cmp' luasnip = require 'luasnip' -luasnip.setup() +-- require 'user.snippets' +-- luasnip.setup() local expnoresilent = {expr = true, noremap = true, silent = true} local noresilent = {noremap = true, silent = true} @@ -44,8 +72,6 @@ local supertabforward = function(fallback) cmp.select_next_item() elseif luasnip.expand_or_jumpable() then luasnip.expand_or_jump() - -- elseif stolen_function() then - -- cmp.complete() else fallback() end @@ -80,8 +106,8 @@ cmp.setup { }, ["<Tab>"] = map(supertabforward, inselect), ["<S-Tab>"] = map(supertabbackward, inselect), - ["<C-k>"] = map(supertabforward, inselect), - ["<C-j>"] = map(supertabbackward, inselect), + ["<C-k>"] = map.scroll_docs(2), + ["<C-j>"] = map.scroll_docs(-2), ["<C-l>"] = map(superenterconfirm, inselect), ["<C-h>"] = map(function(fallback) if cmp.visible() then diff --git a/.config/nvim/lua/user/lsp/rust.lua b/.config/nvim/lua/user/lsp/rust.lua index def29af..41cb03c 100644 --- a/.config/nvim/lua/user/lsp/rust.lua +++ b/.config/nvim/lua/user/lsp/rust.lua @@ -1,24 +1,35 @@ -lsp = require 'lspconfig' +local lsp = require 'lspconfig' +local rust = require 'rust-tools' -vim.cmd [[ - autocmd FileType rust highlight link rustLifetime SpecialComment -]] +-- vim.cmd [[ +-- autocmd FileType rust highlight link rustLifetime SpecialComment +-- ]] -vim.cmd [[ - autocmd FileType rust setlocal inccommand=nosplit -]] +-- 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 = true }, - inlayHints = { typeHints = true }, - }, +-- 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 = true }, +-- inlayHints = { typeHints = true }, +-- }, +-- }, +-- } + +rust.setup{ + server = { + on_attach = function(_, bufnr) + vim.keymap.set("n", "<leader> ", rust.hover_actions.hover_actions, { buffer = bufnr }) + vim.keymap.set("n", "<leader>a", rust.code_action_group.code_action_group, { buffer = bufnr }) + end, }, } + diff --git a/.config/nvim/lua/user/lspinit.lua b/.config/nvim/lua/user/lspinit.lua index 61f203b..4a75ec2 100644 --- a/.config/nvim/lua/user/lspinit.lua +++ b/.config/nvim/lua/user/lspinit.lua @@ -1,4 +1,3 @@ - require'nvim-autopairs'.setup{} require 'user.lsp.common' require 'user.lsp.haskell' diff --git a/.config/nvim/lua/user/plugins.lua b/.config/nvim/lua/user/plugins.lua index 57fcef1..da0d366 100644 --- a/.config/nvim/lua/user/plugins.lua +++ b/.config/nvim/lua/user/plugins.lua @@ -34,6 +34,9 @@ plugins = { "neovim/nvim-lspconfig", -- LSP configuration event = { "InsertEnter" }, }, + { + "simrat39/rust-tools.nvim", + }, -- { "hrsh7th/vim-vsnip" }, -- snippet engine @@ -87,7 +90,12 @@ plugins = { require('crates').setup() end, }, - + { + 'akinsho/bufferline.nvim', -- tab & buffer line + version = "*", + -- dependencies = 'nvim-tree/nvim-web-devicons' + -- for more details on how to configure this plugin in details please see `:h bufferline-configuration` + }, --{ "lvimuser/lsp-inlayhints.nvim" } -- saved for the better times } @@ -115,6 +123,8 @@ vim.opt.rtp:prepend(lazypath) -- initialization lazy = require("lazy") lazy.setup(plugins, opts) --- lazy.load('nerdtree') + +-- miscellanous plugin setup +require('bufferline').setup{} diff --git a/.config/nvim/lua/user/snippets.lua b/.config/nvim/lua/user/snippets.lua new file mode 100644 index 0000000..d1b3090 --- /dev/null +++ b/.config/nvim/lua/user/snippets.lua @@ -0,0 +1,18 @@ +local luasnip = require 'luasnip' + +local text = luasnip.text_node +local snip = luasnip.snippet + +-- local snippets = { +-- rust = { +-- constant_string = snip({ +-- trig = "pubconst", +-- namr = "define a string constant", +-- dscr = "I am too lazy", +-- }, +-- text { "pub const ${1:name}: &str = \"${2:text}\";", } +-- ) +-- }, +-- } + +luasnip.add_snippets(snippets) diff --git a/.config/nvim/lua/user/treesitter.lua b/.config/nvim/lua/user/treesitter.lua new file mode 100644 index 0000000..b98311f --- /dev/null +++ b/.config/nvim/lua/user/treesitter.lua @@ -0,0 +1,20 @@ +--! tree-sitter configuration + + +local ts = require 'nvim-treesitter' +local tsc = require 'nvim-treesitter.configs' + +tsc.setup{ + ensure_installed = { "rust" }, + auto_install = true, + highlight = { + enable = true, + additional_vim_regex_highlighting = true, ---------------------- + }, + ident = { enable = true }, + rainbow = { + enable = true, + extended_mode = true, + max_file_lines = 1024, + }, +} |