diff --git a/config/nvim/init.lua b/config/nvim/init.lua index a7167870..41107593 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -18,8 +18,11 @@ augroup AutoSaveGroup autocmd BufWinLeave,BufLeave,BufWritePost,BufHidden,QuitPre ?* nested silent! mkview! autocmd BufWinEnter ?* silent! loadview augroup end +au BufNewFile,BufRead,BufReadPost *.html.tera set syntax=HTML ]], false) +vim.o.number = true +vim.o.relativenumber = true vim.o.timeoutlen = 700 vim.o.guifont='Hasklug Nerd Font Mono,Hack Nerd Font,NotoEmoji Nerd Font' @@ -49,6 +52,7 @@ vim.wo.signcolumn='yes' vim.g.dashboard_default_executive = 'fzf' vim.g.python_highlight_all = 1 + vim.g.test = { default = { default = { @@ -60,3 +64,55 @@ vim.g.test = { }, rust = { { complete_items = {'ts'} } }, } + + +-- Temp + +vim.o.completeopt = 'menuone,noselect' + +-- -- luasnip setup +-- local luasnip = require 'luasnip' + +-- -- nvim-cmp setup +-- local cmp = require 'cmp' +-- cmp.setup { +-- snippet = { +-- expand = function(args) +-- require('luasnip').lsp_expand(args.body) +-- end, +-- }, +-- mapping = { +-- [''] = cmp.mapping.select_prev_item(), +-- [''] = cmp.mapping.select_next_item(), +-- [''] = cmp.mapping.scroll_docs(-4), +-- [''] = cmp.mapping.scroll_docs(4), +-- [''] = cmp.mapping.complete(), +-- [''] = cmp.mapping.close(), +-- [''] = cmp.mapping.confirm { +-- behavior = cmp.ConfirmBehavior.Replace, +-- select = true, +-- }, +-- [''] = function(fallback) +-- if cmp.visible() then +-- cmp.select_next_item() +-- elseif luasnip.expand_or_jumpable() then +-- luasnip.expand_or_jump() +-- else +-- fallback() +-- end +-- end, +-- [''] = function(fallback) +-- if cmp.visible() then +-- cmp.select_prev_item() +-- elseif luasnip.jumpable(-1) then +-- luasnip.jump(-1) +-- else +-- fallback() +-- end +-- end, +-- }, +-- sources = { +-- { name = 'nvim_lsp' }, +-- { name = 'luasnip' }, +-- }, +-- } diff --git a/config/nvim/lua/keymaps.lua b/config/nvim/lua/keymaps.lua index c9e7f80e..2b0feea1 100644 --- a/config/nvim/lua/keymaps.lua +++ b/config/nvim/lua/keymaps.lua @@ -43,25 +43,7 @@ local normal_mode_maps = { } -vim.api.nvim_command([[imap (completion_smart_tab)]]) -vim.api.nvim_command([[imap (completion_smart_s_tab)]]) - local insert_mode_maps = { - -- { - -- key = '', - -- map = [[pumvisible() ? "\" : "\"]], - -- options = { noremap = true, silent = true, expr = true } - -- }, - - -- { - -- key = '', - -- map = [[pumvisible() ? "\" : "\"]], - -- options = { noremap = true, silent = true, expr = true } - -- }, - - -- { key = '', map = '(completion_smart_tab)', options = { plug = true } }, - -- { key = '', map = '(completion_smart_s_tab)', options = { plug = true } }, - { key = '', map = '' }, } diff --git a/config/nvim/lua/lsp/init.lua b/config/nvim/lua/lsp/init.lua index e78d084d..7b9115d5 100644 --- a/config/nvim/lua/lsp/init.lua +++ b/config/nvim/lua/lsp/init.lua @@ -3,13 +3,14 @@ require("lsp.rust-analyzer") require("lsp.lua-language-server") -require("lsp.pyls") +-- require("lsp.pyls") -- Set completeopt to have a better completion experience -vim.o.completeopt= "menuone,noinsert,noselect" +vim.o.completeopt= "menuone,noselect" -- vim.api.nvim_command [[autocmd CursorHold lua vim.lsp.buf.document_highlight()]] -- vim.api.nvim_command [[autocmd CursorHoldI lua vim.lsp.buf.document_highlight()]] -- vim.api.nvim_command [[autocmd CursorMoved lua vim.lsp.buf.clear_references()]] -- vim.api.nvim_buf_set_option(0, 'omnifunc', 'v:lua.vim.lsp.omnifunc') +-- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') diff --git a/config/nvim/lua/lsp/rust-analyzer.lua b/config/nvim/lua/lsp/rust-analyzer.lua index 5992bfa0..11102753 100644 --- a/config/nvim/lua/lsp/rust-analyzer.lua +++ b/config/nvim/lua/lsp/rust-analyzer.lua @@ -1,23 +1,33 @@ --- Built in lsp local lspconfig = require'lspconfig' --- local lspstatus = require('lsp-status') --- lspstatus.register_progress() + lspconfig.rust_analyzer.setup{ - on_attach=function(client) require'completion'.on_attach(client) require'lsp-status'.on_attach(client) return end, + on_attach=function(client) require'lsp-status'.on_attach(client) return end, + capabilities = require'lsp-status'.capabilities, cmd = { "rust-analyzer" }, filetypes = { "rust" }, root_dir = lspconfig.util.root_pattern("Cargo.toml"), settings = { ["rust-analyzer"] = { + assist = { + importGranularity = "module", + importPrefix = "by_self", + }, + procMacro = { + enable = true, + }, checkOnSave = { command = "clippy", + allTargets = true, }, cargo = { + loadOutDirsFromCheck = true, allFeatures = true, - -- target = "aarch64-linux-android" } } } } +lspconfig.rust_analyzer.setup{ + capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) +} diff --git a/config/nvim/lua/nvim-cmp.lua b/config/nvim/lua/nvim-cmp.lua new file mode 100644 index 00000000..e63592fd --- /dev/null +++ b/config/nvim/lua/nvim-cmp.lua @@ -0,0 +1,47 @@ + -- luasnip setup +local luasnip = require'luasnip' + + -- nvim-cmp setup +local cmp = require'cmp' + cmp.setup { + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + mapping = { + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, + [''] = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, + } + diff --git a/config/nvim/lua/plugins.lua b/config/nvim/lua/plugins.lua index 783c2f09..1fe45f8b 100644 --- a/config/nvim/lua/plugins.lua +++ b/config/nvim/lua/plugins.lua @@ -14,6 +14,7 @@ return require('packer').startup(function() -- Packer can manage itself use 'wbthomason/packer.nvim' + use { 'glepnir/galaxyline.nvim', branch = 'main', config = function() require('statusline') end, @@ -51,34 +52,42 @@ return require('packer').startup(function() -- lsp use { 'onsails/lspkind-nvim', config = function() require'lspkind'.init() end, } use { 'folke/lsp-trouble.nvim', config = function() require("trouble").setup() end, } + use { 'neovim/nvim-lspconfig', config = function() require("lsp") end, } - use { 'nvim-lua/completion-nvim' } use { 'nvim-lua/lsp-status.nvim' } - -- use { 'folke/lsp-colors.nvim' } + + + use { + 'hrsh7th/nvim-cmp', + requires = { 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-buffer', 'saadparwaiz1/cmp_luasnip', 'L3MON4D3/LuaSnip' }, + config = function() require'nvim-cmp' end, + } + + use { 'folke/lsp-colors.nvim' } use { 'nvim-lua/lsp_extensions.nvim' } -- config = function() vim.cmd([[autocmd BufEnter,BufWinEnter,TabEnter *.rs :lua require'lsp_extensions'.inlay_hints()]]) end, -- -- Qol use { 'sindrets/diffview.nvim' } - use { 'justinmk/vim-sneak' } + -- use { 'justinmk/vim-sneak' } use { - 'akinsho/nvim-toggleterm.lua', - config = function() require'setup.toggleterm' end, + 'akinsho/nvim-toggleterm.lua', + config = function() require'setup.toggleterm' end, } use { 'airblade/vim-rooter' } use { 'glepnir/dashboard-nvim' } -- Treesitter {{{ - use { 'nvim-treesitter/nvim-treesitter' } - use { 'nvim-treesitter/completion-treesitter' } + -- use { 'nvim-treesitter/nvim-treesitter' } + -- use { 'nvim-treesitter/completion-treesitter' } --- }}} --: rust {{{ use { 'rust-lang/rust.vim', 'mhinz/vim-crates', - 'cespare/vim-toml', + 'cespare/vim-toml', } -- }}} use { 'vim-python/python-syntax' } diff --git a/config/nvim/lua/statusline.lua b/config/nvim/lua/statusline.lua index f119e2d7..d5cc003b 100644 --- a/config/nvim/lua/statusline.lua +++ b/config/nvim/lua/statusline.lua @@ -3,7 +3,7 @@ local gl = require('galaxyline') local condition = require('galaxyline.condition') -- local diagnostic = require('galaxyline.provider_diagnostic') --- local diagnostics = require('lsp-status.diagnostics') +local diagnostic = require('lsp-status.diagnostics') local vcs = require('galaxyline.provider_vcs') local fileinfo = require('galaxyline.provider_fileinfo') -- local extension = require('galaxyline.provider_extensions') @@ -11,7 +11,7 @@ local fileinfo = require('galaxyline.provider_fileinfo') -- local buffer = require('galaxyline.provider_buffer') -- local whitespace = require('galaxyline.provider_whitespace') -- local lspclient = require('galaxyline.provider_lsp') -local lspstatus = require('lsp-status') +local lsp_status = require('lsp-status') -- local gls = gl.section @@ -21,6 +21,8 @@ gl.short_line_list = { 'defx' } local colors = { dark_black = '#151515', black = '#181819', + + bg = '#151515', -- same as dark_black bg0 = '#2c2e34', bg1 = '#30323a', bg2 = '#363944', @@ -121,34 +123,68 @@ gls.left[2] = { gls.left[3] = { ShowLspStatus = { - provider = lspstatus.status, + provider = lsp_status.status, highlight = { colors.grey , colors.dark_black, 'bold' } } } -- Right Side -gls.right[1]= { - FileFormat = { - provider = function() return ' '..fileinfo.get_file_format()..' ' end, - highlight = { colors.purple, colors.bg3 }, - separator = '', - separator_highlight = { colors.bg3, colors.dark_black }, +-- gls.right[1]= { +-- FileFormat = { +-- provider = function() return ' '..fileinfo.get_file_format()..' ' end, +-- highlight = { colors.purple, colors.bg3 }, +-- separator = '', +-- separator_highlight = { colors.bg3, colors.dark_black }, +-- } +-- } + + +gls.right[1] = { + DiagnosticError = { + provider = 'DiagnosticError', + icon = '  ', + highlight = {colors.red,colors.bg} } } gls.right[2] = { + DiagnosticWarn = { + provider = 'DiagnosticWarn', + icon = '  ', + highlight = {colors.yellow,colors.bg}, + } +} + +gls.right[3] = { + DiagnosticHint = { + provider = 'DiagnosticHint', + icon = '  ', + highlight = {colors.cyan,colors.bg}, + } +} + +gls.right[4] = { + DiagnosticInfo = { + provider = 'DiagnosticInfo', + icon = '  ', + highlight = {colors.blue,colors.bg}, + } +} + +gls.right[5] = { LineInfo = { provider = 'LineColumn', - highlight = { colors.grey, colors.bg2 }, + highlight = { colors.grey , colors.bg3 }, separator = '', - separator_highlight = { colors.bg2, colors.bg3 }, + separator_highlight = { colors.bg3, colors.dark_black }, }, } -gls.right[3] = { +gls.right[6] = { PerCent = { provider = 'LinePercent', highlight = { colors.blue, colors.bg1 }, separator = '', - separator_highlight = { colors.bg1 , colors.bg2 }, + separator_highlight = { colors.bg1 , colors.bg3 }, } } +