Many changes to nvim configs
- switch to nvim-cmp - add lsp-status stuff to statusline
This commit is contained in:
@@ -18,8 +18,11 @@ augroup AutoSaveGroup
|
|||||||
autocmd BufWinLeave,BufLeave,BufWritePost,BufHidden,QuitPre ?* nested silent! mkview!
|
autocmd BufWinLeave,BufLeave,BufWritePost,BufHidden,QuitPre ?* nested silent! mkview!
|
||||||
autocmd BufWinEnter ?* silent! loadview
|
autocmd BufWinEnter ?* silent! loadview
|
||||||
augroup end
|
augroup end
|
||||||
|
au BufNewFile,BufRead,BufReadPost *.html.tera set syntax=HTML
|
||||||
]], false)
|
]], false)
|
||||||
|
|
||||||
|
vim.o.number = true
|
||||||
|
vim.o.relativenumber = true
|
||||||
vim.o.timeoutlen = 700
|
vim.o.timeoutlen = 700
|
||||||
vim.o.guifont='Hasklug Nerd Font Mono,Hack Nerd Font,NotoEmoji Nerd Font'
|
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.dashboard_default_executive = 'fzf'
|
||||||
vim.g.python_highlight_all = 1
|
vim.g.python_highlight_all = 1
|
||||||
|
|
||||||
|
|
||||||
vim.g.test = {
|
vim.g.test = {
|
||||||
default = {
|
default = {
|
||||||
default = {
|
default = {
|
||||||
@@ -60,3 +64,55 @@ vim.g.test = {
|
|||||||
},
|
},
|
||||||
rust = { { complete_items = {'ts'} } },
|
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 = {
|
||||||
|
-- ['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||||
|
-- ['<C-n>'] = cmp.mapping.select_next_item(),
|
||||||
|
-- ['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
-- ['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
-- ['<C-Space>'] = cmp.mapping.complete(),
|
||||||
|
-- ['<C-e>'] = cmp.mapping.close(),
|
||||||
|
-- ['<CR>'] = cmp.mapping.confirm {
|
||||||
|
-- behavior = cmp.ConfirmBehavior.Replace,
|
||||||
|
-- select = true,
|
||||||
|
-- },
|
||||||
|
-- ['<Tab>'] = function(fallback)
|
||||||
|
-- if cmp.visible() then
|
||||||
|
-- cmp.select_next_item()
|
||||||
|
-- elseif luasnip.expand_or_jumpable() then
|
||||||
|
-- luasnip.expand_or_jump()
|
||||||
|
-- else
|
||||||
|
-- fallback()
|
||||||
|
-- end
|
||||||
|
-- end,
|
||||||
|
-- ['<S-Tab>'] = 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' },
|
||||||
|
-- },
|
||||||
|
-- }
|
||||||
|
|||||||
@@ -43,25 +43,7 @@ local normal_mode_maps = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vim.api.nvim_command([[imap <tab> <Plug>(completion_smart_tab)]])
|
|
||||||
vim.api.nvim_command([[imap <s-tab> <Plug>(completion_smart_s_tab)]])
|
|
||||||
|
|
||||||
local insert_mode_maps = {
|
local insert_mode_maps = {
|
||||||
-- {
|
|
||||||
-- key = '<Tab>',
|
|
||||||
-- map = [[pumvisible() ? "\<C-n>" : "\<Tab>"]],
|
|
||||||
-- options = { noremap = true, silent = true, expr = true }
|
|
||||||
-- },
|
|
||||||
|
|
||||||
-- {
|
|
||||||
-- key = '<S-Tab>',
|
|
||||||
-- map = [[pumvisible() ? "\<C-p>" : "\<S-Tab>"]],
|
|
||||||
-- options = { noremap = true, silent = true, expr = true }
|
|
||||||
-- },
|
|
||||||
|
|
||||||
-- { key = '<tab>', map = '(completion_smart_tab)', options = { plug = true } },
|
|
||||||
-- { key = '<s-tab>', map = '(completion_smart_s_tab)', options = { plug = true } },
|
|
||||||
|
|
||||||
{ key = '<C-j>', map = '<ESC>' },
|
{ key = '<C-j>', map = '<ESC>' },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,14 @@
|
|||||||
|
|
||||||
require("lsp.rust-analyzer")
|
require("lsp.rust-analyzer")
|
||||||
require("lsp.lua-language-server")
|
require("lsp.lua-language-server")
|
||||||
require("lsp.pyls")
|
-- require("lsp.pyls")
|
||||||
|
|
||||||
-- Set completeopt to have a better completion experience
|
-- 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 <buffer> lua vim.lsp.buf.document_highlight()]]
|
-- vim.api.nvim_command [[autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()]]
|
||||||
-- vim.api.nvim_command [[autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()]]
|
-- vim.api.nvim_command [[autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()]]
|
||||||
-- vim.api.nvim_command [[autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()]]
|
-- vim.api.nvim_command [[autocmd CursorMoved <buffer> 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(0, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
-- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
|||||||
@@ -1,23 +1,33 @@
|
|||||||
-- Built in lsp
|
|
||||||
local lspconfig = require'lspconfig'
|
local lspconfig = require'lspconfig'
|
||||||
-- local lspstatus = require('lsp-status')
|
|
||||||
-- lspstatus.register_progress()
|
|
||||||
|
|
||||||
lspconfig.rust_analyzer.setup{
|
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" },
|
cmd = { "rust-analyzer" },
|
||||||
filetypes = { "rust" },
|
filetypes = { "rust" },
|
||||||
root_dir = lspconfig.util.root_pattern("Cargo.toml"),
|
root_dir = lspconfig.util.root_pattern("Cargo.toml"),
|
||||||
settings = {
|
settings = {
|
||||||
["rust-analyzer"] = {
|
["rust-analyzer"] = {
|
||||||
|
assist = {
|
||||||
|
importGranularity = "module",
|
||||||
|
importPrefix = "by_self",
|
||||||
|
},
|
||||||
|
procMacro = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
checkOnSave = {
|
checkOnSave = {
|
||||||
command = "clippy",
|
command = "clippy",
|
||||||
|
allTargets = true,
|
||||||
},
|
},
|
||||||
cargo = {
|
cargo = {
|
||||||
|
loadOutDirsFromCheck = true,
|
||||||
allFeatures = true,
|
allFeatures = true,
|
||||||
-- target = "aarch64-linux-android"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lspconfig.rust_analyzer.setup{
|
||||||
|
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
}
|
||||||
|
|||||||
47
config/nvim/lua/nvim-cmp.lua
Normal file
47
config/nvim/lua/nvim-cmp.lua
Normal file
@@ -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 = {
|
||||||
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||||
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||||
|
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
|
['<C-e>'] = cmp.mapping.close(),
|
||||||
|
['<CR>'] = cmp.mapping.confirm {
|
||||||
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
|
select = true,
|
||||||
|
},
|
||||||
|
['<Tab>'] = function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif luasnip.expand_or_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
['<S-Tab>'] = 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' },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
@@ -14,6 +14,7 @@ return require('packer').startup(function()
|
|||||||
-- Packer can manage itself
|
-- Packer can manage itself
|
||||||
use 'wbthomason/packer.nvim'
|
use 'wbthomason/packer.nvim'
|
||||||
|
|
||||||
|
|
||||||
use {
|
use {
|
||||||
'glepnir/galaxyline.nvim', branch = 'main',
|
'glepnir/galaxyline.nvim', branch = 'main',
|
||||||
config = function() require('statusline') end,
|
config = function() require('statusline') end,
|
||||||
@@ -51,16 +52,24 @@ return require('packer').startup(function()
|
|||||||
-- lsp
|
-- lsp
|
||||||
use { 'onsails/lspkind-nvim', config = function() require'lspkind'.init() end, }
|
use { 'onsails/lspkind-nvim', config = function() require'lspkind'.init() end, }
|
||||||
use { 'folke/lsp-trouble.nvim', config = function() require("trouble").setup() end, }
|
use { 'folke/lsp-trouble.nvim', config = function() require("trouble").setup() end, }
|
||||||
|
|
||||||
use { 'neovim/nvim-lspconfig', config = function() require("lsp") end, }
|
use { 'neovim/nvim-lspconfig', config = function() require("lsp") end, }
|
||||||
use { 'nvim-lua/completion-nvim' }
|
|
||||||
use { 'nvim-lua/lsp-status.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' }
|
use { 'nvim-lua/lsp_extensions.nvim' }
|
||||||
-- config = function() vim.cmd([[autocmd BufEnter,BufWinEnter,TabEnter *.rs :lua require'lsp_extensions'.inlay_hints()]]) end,
|
-- config = function() vim.cmd([[autocmd BufEnter,BufWinEnter,TabEnter *.rs :lua require'lsp_extensions'.inlay_hints()]]) end,
|
||||||
--
|
--
|
||||||
-- Qol
|
-- Qol
|
||||||
use { 'sindrets/diffview.nvim' }
|
use { 'sindrets/diffview.nvim' }
|
||||||
use { 'justinmk/vim-sneak' }
|
-- use { 'justinmk/vim-sneak' }
|
||||||
use {
|
use {
|
||||||
'akinsho/nvim-toggleterm.lua',
|
'akinsho/nvim-toggleterm.lua',
|
||||||
config = function() require'setup.toggleterm' end,
|
config = function() require'setup.toggleterm' end,
|
||||||
@@ -70,8 +79,8 @@ return require('packer').startup(function()
|
|||||||
use { 'glepnir/dashboard-nvim' }
|
use { 'glepnir/dashboard-nvim' }
|
||||||
|
|
||||||
-- Treesitter {{{
|
-- Treesitter {{{
|
||||||
use { 'nvim-treesitter/nvim-treesitter' }
|
-- use { 'nvim-treesitter/nvim-treesitter' }
|
||||||
use { 'nvim-treesitter/completion-treesitter' }
|
-- use { 'nvim-treesitter/completion-treesitter' }
|
||||||
--- }}}
|
--- }}}
|
||||||
|
|
||||||
--: rust {{{
|
--: rust {{{
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ local gl = require('galaxyline')
|
|||||||
|
|
||||||
local condition = require('galaxyline.condition')
|
local condition = require('galaxyline.condition')
|
||||||
-- local diagnostic = require('galaxyline.provider_diagnostic')
|
-- 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 vcs = require('galaxyline.provider_vcs')
|
||||||
local fileinfo = require('galaxyline.provider_fileinfo')
|
local fileinfo = require('galaxyline.provider_fileinfo')
|
||||||
-- local extension = require('galaxyline.provider_extensions')
|
-- local extension = require('galaxyline.provider_extensions')
|
||||||
@@ -11,7 +11,7 @@ local fileinfo = require('galaxyline.provider_fileinfo')
|
|||||||
-- local buffer = require('galaxyline.provider_buffer')
|
-- local buffer = require('galaxyline.provider_buffer')
|
||||||
-- local whitespace = require('galaxyline.provider_whitespace')
|
-- local whitespace = require('galaxyline.provider_whitespace')
|
||||||
-- local lspclient = require('galaxyline.provider_lsp')
|
-- local lspclient = require('galaxyline.provider_lsp')
|
||||||
local lspstatus = require('lsp-status')
|
local lsp_status = require('lsp-status')
|
||||||
|
|
||||||
|
|
||||||
-- local gls = gl.section
|
-- local gls = gl.section
|
||||||
@@ -21,6 +21,8 @@ gl.short_line_list = { 'defx' }
|
|||||||
local colors = {
|
local colors = {
|
||||||
dark_black = '#151515',
|
dark_black = '#151515',
|
||||||
black = '#181819',
|
black = '#181819',
|
||||||
|
|
||||||
|
bg = '#151515', -- same as dark_black
|
||||||
bg0 = '#2c2e34',
|
bg0 = '#2c2e34',
|
||||||
bg1 = '#30323a',
|
bg1 = '#30323a',
|
||||||
bg2 = '#363944',
|
bg2 = '#363944',
|
||||||
@@ -121,34 +123,68 @@ gls.left[2] = {
|
|||||||
|
|
||||||
gls.left[3] = {
|
gls.left[3] = {
|
||||||
ShowLspStatus = {
|
ShowLspStatus = {
|
||||||
provider = lspstatus.status,
|
provider = lsp_status.status,
|
||||||
highlight = { colors.grey , colors.dark_black, 'bold' }
|
highlight = { colors.grey , colors.dark_black, 'bold' }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-- Right Side
|
-- Right Side
|
||||||
gls.right[1]= {
|
-- gls.right[1]= {
|
||||||
FileFormat = {
|
-- FileFormat = {
|
||||||
provider = function() return ' '..fileinfo.get_file_format()..' ' end,
|
-- provider = function() return ' '..fileinfo.get_file_format()..' ' end,
|
||||||
highlight = { colors.purple, colors.bg3 },
|
-- highlight = { colors.purple, colors.bg3 },
|
||||||
separator = '',
|
-- separator = '',
|
||||||
separator_highlight = { colors.bg3, colors.dark_black },
|
-- separator_highlight = { colors.bg3, colors.dark_black },
|
||||||
|
-- }
|
||||||
|
-- }
|
||||||
|
|
||||||
|
|
||||||
|
gls.right[1] = {
|
||||||
|
DiagnosticError = {
|
||||||
|
provider = 'DiagnosticError',
|
||||||
|
icon = ' ',
|
||||||
|
highlight = {colors.red,colors.bg}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gls.right[2] = {
|
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 = {
|
LineInfo = {
|
||||||
provider = 'LineColumn',
|
provider = 'LineColumn',
|
||||||
highlight = { colors.grey, colors.bg2 },
|
highlight = { colors.grey , colors.bg3 },
|
||||||
separator = '',
|
separator = '',
|
||||||
separator_highlight = { colors.bg2, colors.bg3 },
|
separator_highlight = { colors.bg3, colors.dark_black },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
gls.right[3] = {
|
gls.right[6] = {
|
||||||
PerCent = {
|
PerCent = {
|
||||||
provider = 'LinePercent',
|
provider = 'LinePercent',
|
||||||
highlight = { colors.blue, colors.bg1 },
|
highlight = { colors.blue, colors.bg1 },
|
||||||
separator = '',
|
separator = '',
|
||||||
separator_highlight = { colors.bg1 , colors.bg2 },
|
separator_highlight = { colors.bg1 , colors.bg3 },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user