Added some more stuff to neovim lua config

This commit is contained in:
Uttarayan Mondal
2021-05-13 20:34:42 +05:30
parent e8189ba975
commit 76f211a525
8 changed files with 142 additions and 50 deletions

View File

@@ -1,3 +1,4 @@
-- local vim = vim
require('plugins')
require('keymaps')
@@ -6,12 +7,21 @@ vim.api.nvim_exec([[
augroup Packer
autocmd!
autocmd BufWritePost init.lua PackerCompile
autocmd BufWritePost keymaps.lua PackerCompile
autocmd BufWritePost plugins.lua PackerCompile
augroup end
]], false)
vim.api.nvim_exec([[
augroup AutoSaveGroup
autocmd!
autocmd BufWinLeave,BufLeave,BufWritePost,BufHidden,QuitPre ?* nested silent! mkview!
autocmd BufWinEnter ?* silent! loadview
augroup end
]], false)
vim.o.timeoutlen = 700
vim.o.guifont='FiraCode Nerd Font Mono'
vim.o.guifont='Hasklug Nerd Font Mono,Hack Nerd Font,NotoEmoji Nerd Font'
vim.o.undodir=vim.fn.stdpath('cache')..'/undodir'
vim.o.undofile = true
@@ -19,8 +29,13 @@ vim.o.undofile = true
vim.o.showmode = false
vim.o.showtabline = 2
vim.o.autoindent = true
vim.o.tabstop=4
vim.o.softtabstop=4
vim.o.shiftwidth=4
vim.bo.shiftwidth=4
vim.o.expandtab = true
vim.o.hidden = true
vim.o.ignorecase = true
@@ -28,3 +43,20 @@ vim.o.smartcase = true
vim.o.termguicolors = true
-- No clue why window scoped
vim.wo.signcolumn='yes'
-- vim.o.modifiable = true
-- vim.bo.modifiable = true
vim.g.dashboard_default_executive = 'fzf'
vim.g.python_highlight_all = 1
vim.g.test = {
default = {
default = {
complete_items = { 'lsp', 'snippet' },
mode = 'file',
},
comment = {},
string = { complete_items = { 'path' } },
},
rust = { { complete_items = {'ts'} } },
}

View File

@@ -15,34 +15,49 @@ local normal_mode_maps = {
-- fzf
{ key = '<leader>;', map = [[<cmd>Buffers<cr>]] },
{ key = '<leader>f', map = [[<cmd>Files<cr>]] },
{ key = '<leader>ff', map = [[<cmd>Files<cr>]] },
{ key = '<leader>fb', map = [[<cmd>Marks<cr>]] },
{ key = '<leader>fh', map = [[<cmd>History<cr>]] },
{ key = '<leader>fa', map = [[<cmd>History<cr>]] },
{ key = '<leader>tc', map = [[<cmd>Colors<cr>]] },
{ key = '<leader>g', map = [[<cmd>Rg<cr>]] },
-- Session
{ key = '<leader>ss', map = [[<cmd>SessionSave<cr>]] },
{ key = '<leader>sl', map = [[<cmd>SessionLoad<cr>]] },
-- lsp
{ key = 'K', map = [[<cmd>lua vim.lsp.buf.hover()<cr>]] },
{ key = 'gd', map = [[<cmd>lua vim.lsp.buf.definition()<cr>]] },
{ key = '<C-k>', map = [[<cmd>lua vim.lsp.buf.definition()<cr>]] },
{ key = 'gi', map = [[<cmd>lua vim.lsp.buf.implementation()<cr>]] },
{ key = '<leader>o', map = [[<cmd>LspTroubleToggle<cr>]] },
{ key = '<leader>a', map = [[<cmd>lua vim.lsp.buf.document_highlight()<cr>]] },
{ key = '<leader>c', map = [[<cmd>lua vim.lsp.buf.clear_references()<cr>]] },
-- { key = '<leader>a', map = [[<cmd>lua vim.lsp.buf.document_highlight()<cr>]] },
-- { key = '<leader>c', map = [[<cmd>lua vim.lsp.buf.clear_references()<cr>]] },
{ key = '<leader>"', map = [["+]] },
{ key = 'F', map = [[<cmd>lua vim.lsp.buf.formatting()<cr>]] },
{ key = 'T', map = [[<cmd>lua require'lsp_extensions'.inlay_hints()<cr>]] },
-- Other
{ key = '<leader>m', map = [[<cmd>silent !mpcfzf<cr>]] },
}
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 }
},
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 = {
-- {
-- 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 } },
@@ -55,10 +70,10 @@ for idx = 1, #normal_mode_maps do
if normal_mode_maps[idx].options then
local options = normal_mode_maps[idx].options
vim.api.nvim_set_keymap('n', normal_mode_maps[idx].key, normal_mode_maps[idx].map ,options)
else
else
vim.api.nvim_set_keymap('n', normal_mode_maps[idx].key, normal_mode_maps[idx].map ,options)
end
end
end
for idx = 1, #insert_mode_maps do
if insert_mode_maps[idx].options then
@@ -67,4 +82,13 @@ for idx = 1, #insert_mode_maps do
else
vim.api.nvim_set_keymap('i', insert_mode_maps[idx].key, insert_mode_maps[idx].map ,options)
end
end
end
-- local ff = {
-- { 'this', 'and this' },
-- { 'that', 'and that' },
-- }
-- print(ff[1][2])

View File

@@ -3,6 +3,7 @@
require("lsp.rust-analyzer")
require("lsp.lua-language-server")
require("lsp.pyls")
-- Set completeopt to have a better completion experience
vim.o.completeopt= "menuone,noinsert,noselect"

View File

@@ -0,0 +1,6 @@
local lspconfig = require'lspconfig'
lspconfig.pyls.setup{
cmd = { "pyls" },
filetypes = { "python" },
}

View File

@@ -11,10 +11,11 @@ lspconfig.rust_analyzer.setup{
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy";
command = "clippy",
},
cargo = {
allFeatures = true;
allFeatures = true,
-- target = "aarch64-linux-android"
}
}
}

View File

@@ -1,3 +1,4 @@
local vim = vim
local execute = vim.api.nvim_command
local fn = vim.fn
@@ -44,30 +45,41 @@ return require('packer').startup(function()
'tpope/vim-commentary',
'tpope/vim-fugitive',
}
use { 'norcalli/nvim-colorizer.lua', config = function() require'colorizer'.setup() end, }
-- lsp
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 { 'nvim-lua/completion-nvim' }
use { 'nvim-lua/lsp-status.nvim' }
use {
'nvim-lua/lsp_extensions.nvim',
config =
function()
vim.api.nvim_command([[autocmd BufEnter,BufWinEnter,TabEnter *.rs :lua require'lsp_extensions'.inlay_hints{}]])
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 {
'akinsho/nvim-toggleterm.lua',
config = function() require'setup.toggleterm' end,
}
use { 'airblade/vim-rooter' }
use { 'glepnir/dashboard-nvim' }
-- rust {{{
-- 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' }
end)

View File

@@ -0,0 +1,31 @@
require("toggleterm").setup{
size = 70,
open_mapping = [[<c-\>]],
hide_numbers = true, -- hide the number column in toggleterm buffers
shade_filetypes = {},
shade_terminals = true,
shading_factor = '1', -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light
start_in_insert = true,
persist_size = true,
-- direction = 'vertical' | 'horizontal' | 'window' | 'float',
direction = 'vertical',
close_on_exit = true, -- close the terminal window when the process exits
shell = vim.o.shell, -- change the default shell
-- This field is only relevant if direction is set to 'float'
float_opts = {
-- The border key is *almost* the same as 'nvim_win_open'
-- see :h nvim_win_open for details on borders however
-- the 'curved' border is a custom border type
-- not natively supported but implemented in this plugin.
-- border = 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open
border = 'single',
width = 30,
height = 30,
winblend = 3,
highlights = {
border = "Normal",
background = "Normal",
}
}
}

View File

@@ -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 diagnostics = require('lsp-status.diagnostics')
local vcs = require('galaxyline.provider_vcs')
local fileinfo = require('galaxyline.provider_fileinfo')
-- local extension = require('galaxyline.provider_extensions')
@@ -36,12 +36,13 @@ local colors = {
bg_blue = '#85d3f2',
diff_blue = '#354157',
yellow = '#e7c664',
diff_yellow = '#4e432f',
fg = '#e2e2e3',
red = '#fc5d7c',
orange = '#f39660',
yellow = '#e7c664',
green = '#9ed072',
blue = '#76cce0',
purple = '#b39df3',
@@ -107,14 +108,6 @@ gls.left[1] = {
}
}
-- gls.left[2] = {
-- GitIcon = {
-- provider = function() return '  ' end,
-- condition = condition.check_git_workspace,
-- highlight = { colors.purple , colors.bg1 },
-- }
-- }
gls.left[2] = {
GitBranch = {
provider = function() return vcs.get_git_branch()..' ' end,
@@ -129,15 +122,7 @@ gls.left[2] = {
gls.left[3] = {
ShowLspStatus = {
provider = lspstatus.status,
-- condition = function ()
-- local tbl = {['dashboard'] = true,['']=true}
-- if tbl[vim.bo.filetype] then
-- return false
-- end
-- return true
-- end,
-- icon = '  LSP:',
highlight = { colors.diff_yellow , colors.dark_black, 'bold' }
highlight = { colors.grey , colors.dark_black, 'bold' }
}
}