feat: lualine config and stuff
This commit is contained in:
parent
c45475a62d
commit
e7ab3b8f26
|
@ -26,6 +26,8 @@ opt.splitright = true -- Put new windows right of current
|
|||
opt.wrap = false -- Disable line wrap
|
||||
opt.wildmode = {'list', 'longest'} -- Command-line completion mode
|
||||
|
||||
opt.completeopt = {"menu", "menuone", "noselect"}
|
||||
|
||||
-- Set theme
|
||||
require('github-theme').setup({theme_style = "light", dark_float = true})
|
||||
|
||||
|
|
|
@ -1,19 +1,47 @@
|
|||
local M = {}
|
||||
|
||||
local function has_words_before ()
|
||||
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
|
||||
|
||||
function M.setup()
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup({
|
||||
local lspkind = require('lspkind')
|
||||
local options = {
|
||||
formatting = {format = lspkind.cmp_format()},
|
||||
mapping = {
|
||||
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), {'i', 'c'}),
|
||||
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), {'i', 'c'}),
|
||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), {'i', 'c'}),
|
||||
-- ['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), {'i', 'c'}),
|
||||
['<C-y>'] = cmp.config.disable,
|
||||
['<C-e>'] = cmp.mapping({i = cmp.mapping.abort(), c = cmp.mapping.close()}),
|
||||
['<CR>'] = cmp.mapping.confirm({select = true})
|
||||
['<CR>'] = cmp.mapping.confirm({select = true}),
|
||||
-- https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings
|
||||
['<C-Space>'] = cmp.mapping.confirm {behavior = cmp.ConfirmBehavior.Insert, select = true},
|
||||
['<Tab>'] = function(fallback)
|
||||
if not cmp.select_next_item() then
|
||||
if vim.bo.buftype ~= 'prompt' and has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end
|
||||
end,
|
||||
['<S-Tab>'] = function(fallback)
|
||||
if not cmp.select_prev_item() then
|
||||
if vim.bo.buftype ~= 'prompt' and has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end
|
||||
end,
|
||||
},
|
||||
sources = cmp.config.sources({}, {{name = 'buffer'}})
|
||||
})
|
||||
sources = cmp.config.sources({{name = 'nvim_lsp'}}, {{name = 'buffer'}})
|
||||
}
|
||||
|
||||
cmp.setup(options)
|
||||
|
||||
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline('/', {sources = {{name = 'buffer'}}})
|
||||
|
|
|
@ -4,12 +4,12 @@ function M.setup()
|
|||
-- Other unconfigured plugins
|
||||
require('nvim-autopairs').setup()
|
||||
require("startup").setup({theme = "dashboard"})
|
||||
require('lualine').setup({theme = "github"})
|
||||
|
||||
-- Plugins with their own configs:
|
||||
require("my.plugins.cmp").setup()
|
||||
require("my.plugins.lspconfig").setup()
|
||||
require("my.plugins.null-ls").setup()
|
||||
require("my.plugins.lualine").setup()
|
||||
-- require("my.plugins.fzf-lua").setup()
|
||||
require("my.plugins.treesitter").setup()
|
||||
require("my.plugins.comment").setup()
|
||||
|
|
|
@ -31,7 +31,7 @@ local function on_attach(client, bufnr)
|
|||
-- Code actions
|
||||
map(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>')
|
||||
map(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>')
|
||||
map(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>')
|
||||
-- map(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>')
|
||||
map(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>')
|
||||
map(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>')
|
||||
end
|
||||
|
@ -106,7 +106,7 @@ function M.setup()
|
|||
local autoFormatOn = {lua = 200, purs = 1000, nix = 200, ts = 200, js = 200, json = 200, scss = 200, tsx = 200, jsx = 200}
|
||||
|
||||
-- Auto format
|
||||
for extension, timeout in pairs(autoFormatOn) do
|
||||
for extension, _ in pairs(autoFormatOn) do
|
||||
-- I wonder if this could be done in a single glob pattern
|
||||
cmd("autocmd BufWritePre *." .. extension .. " lua vim.lsp.buf.formatting_sync()")
|
||||
end
|
||||
|
|
12
dotfiles/neovim/lua/my/plugins/lualine.lua
Normal file
12
dotfiles/neovim/lua/my/plugins/lualine.lua
Normal file
|
@ -0,0 +1,12 @@
|
|||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
require('lualine').setup({
|
||||
theme = "github",
|
||||
|
||||
-- Integration with other plugins
|
||||
extensions = {"nvim-tree"}
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
|
@ -13,6 +13,7 @@ local bindings = {
|
|||
-- See diagnostics with space + d
|
||||
lsp_document_diagnostics = "<space>d",
|
||||
lsp_workspace_diagnostics = "<space>wd",
|
||||
lsp_code_actions = "<space>ca",
|
||||
|
||||
-- Open a list with all the pickers
|
||||
builtin = "<space>t",
|
||||
|
|
|
@ -55,6 +55,8 @@ in
|
|||
vimtex # latex plugin
|
||||
null-ls-nvim # generic language server
|
||||
telescope-file-browser-nvim # file creation/deletion using telescope
|
||||
lspkind-nvim # show icons in lsp completion menus
|
||||
symbols-outline-nvim # tree view for symbols in document
|
||||
|
||||
# Cmp related stuff. See https://github.com/hrsh7th/nvim-cmp
|
||||
cmp-nvim-lsp
|
||||
|
|
Loading…
Reference in a new issue