Add word count to status line
This commit is contained in:
parent
06b955efa1
commit
80526d30e5
117
init.lua
117
init.lua
@ -58,6 +58,16 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
||||
client.server_capabilities.semanticTokensProvider = nil
|
||||
end,
|
||||
})
|
||||
|
||||
-- Function to get work count in status line
|
||||
local function getWords()
|
||||
-- the third string here is the string for visual-block mode (^V)
|
||||
if vim.fn.mode() == "v" or vim.fn.mode() == "V" or vim.fn.mode() == "" then
|
||||
return vim.fn.wordcount().visual_words .. ""
|
||||
else
|
||||
return vim.fn.wordcount().words .. ""
|
||||
end
|
||||
end
|
||||
-- [[ Basic Keymaps ]]
|
||||
-- See `:help vim.keymap.set()`
|
||||
|
||||
@ -79,7 +89,6 @@ vim.keymap.set("n", "<C-h>", "<C-w><C-h>", { desc = "Move focus to the left wind
|
||||
vim.keymap.set("n", "<C-l>", "<C-w><C-l>", { desc = "Move focus to the right window" })
|
||||
vim.keymap.set("n", "<C-j>", "<C-w><C-j>", { desc = "Move focus to the lower window" })
|
||||
vim.keymap.set("n", "<C-k>", "<C-w><C-k>", { desc = "Move focus to the upper window" })
|
||||
|
||||
-- [[ Basic Autocommands ]]
|
||||
-- Go back to last edited line when reopening file
|
||||
vim.api.nvim_create_autocmd("BufRead", {
|
||||
@ -91,7 +100,7 @@ vim.api.nvim_create_autocmd("BufRead", {
|
||||
local ft = vim.bo[opts.buf].filetype
|
||||
local last_known_line = vim.api.nvim_buf_get_mark(opts.buf, '"')[1]
|
||||
if
|
||||
not (ft:match("commit") and ft:match("rebase"))
|
||||
not (ft:match("gitcommit") and ft:match("gitrebase"))
|
||||
and last_known_line > 1
|
||||
and last_known_line <= vim.api.nvim_buf_line_count(opts.buf)
|
||||
then
|
||||
@ -182,7 +191,12 @@ require("lazy").setup({
|
||||
npairs.remove_rule("`")
|
||||
end,
|
||||
},
|
||||
"kana/vim-textobj-user",
|
||||
{
|
||||
"GCBallesteros/vim-textobj-hydrogen",
|
||||
dependencies = {
|
||||
"kana/vim-textobj-user",
|
||||
},
|
||||
},
|
||||
"godlygeek/tabular",
|
||||
"tpope/vim-sleuth",
|
||||
{
|
||||
@ -225,8 +239,6 @@ require("lazy").setup({
|
||||
},
|
||||
ignore_blank_lines = true, -- ignore blank lines when sending visual select lines
|
||||
})
|
||||
|
||||
-- iron also has a list of commands, see :h iron-commands for all available commands
|
||||
vim.keymap.set("n", ";rs", "<cmd>IronRepl<cr>")
|
||||
vim.keymap.set("n", ";rr", "<cmd>IronRestart<cr>")
|
||||
vim.keymap.set("n", ";rf", "<cmd>IronFocus<cr>")
|
||||
@ -236,7 +248,7 @@ require("lazy").setup({
|
||||
end,
|
||||
},
|
||||
"tpope/vim-markdown",
|
||||
|
||||
"christoomey/vim-tmux-navigator",
|
||||
-- NOTE: Plugins can specify dependencies.
|
||||
--
|
||||
-- The dependencies are proper plugin specifications as well - anything
|
||||
@ -290,10 +302,21 @@ require("lazy").setup({
|
||||
pcall(require("telescope").load_extension("live_grep_args"))
|
||||
local builtin = require("telescope.builtin")
|
||||
vim.keymap.set("n", "<C-g>", require("telescope").extensions.live_grep_args.live_grep_args)
|
||||
vim.keymap.set("n", "<C-g>", require("telescope").extensions.live_grep_args.live_grep_args)
|
||||
vim.keymap.set(
|
||||
"x",
|
||||
"<C-g>",
|
||||
"\"zy:lua require('telescope').extensions.live_grep_args.live_grep_args(require('telescope.themes').get_ivy({}))<cr><c-r>z"
|
||||
)
|
||||
vim.keymap.set("n", "<C-f>", builtin.find_files)
|
||||
end,
|
||||
},
|
||||
{ -- grammar checking
|
||||
"rhysd/vim-grammarous",
|
||||
ft = { "markdown", "latex" },
|
||||
config = function()
|
||||
vim.g["grammarous#jar_url"] = "https://www.languagetool.org/download/LanguageTool-5.9.zip"
|
||||
end,
|
||||
},
|
||||
{ -- LSP Configuration & Plugins
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
@ -330,7 +353,7 @@ require("lazy").setup({
|
||||
|
||||
-- Jump to the implementation of the word under your cursor.
|
||||
-- Useful when your language has ways of declaring types without an actual implementation.
|
||||
map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
|
||||
map("<leader>I", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
|
||||
|
||||
-- Jump to the type of the word under your cursor.
|
||||
-- Useful when you're not sure what type a variable is and you want to see
|
||||
@ -517,6 +540,35 @@ require("lazy").setup({
|
||||
end
|
||||
return "make install_jsregexp"
|
||||
end)(),
|
||||
config = function()
|
||||
require("luasnip.loaders.from_snipmate").lazy_load({ paths = "./snippets" })
|
||||
local ls = require("luasnip")
|
||||
-- some shorthands...
|
||||
local snip = ls.snippet
|
||||
local node = ls.snippet_node
|
||||
local text = ls.text_node
|
||||
local insert = ls.insert_node
|
||||
local func = ls.function_node
|
||||
local choice = ls.choice_node
|
||||
local dynamicn = ls.dynamic_node
|
||||
|
||||
ls.add_snippets(nil, {
|
||||
python = {
|
||||
snip({
|
||||
trig = "imp",
|
||||
namr = "Imports",
|
||||
dscr = "Comments for imports",
|
||||
}, {
|
||||
text({ "# Core modules", "" }),
|
||||
insert(1),
|
||||
text({ "", "# Non-core modules", "" }),
|
||||
insert(2),
|
||||
text({ "", "# SEI modules", "" }),
|
||||
insert(3),
|
||||
}),
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
@ -550,10 +602,16 @@ require("lazy").setup({
|
||||
-- This will expand snippets if the LSP sent a snippet.
|
||||
["<C-y>"] = cmp.mapping.confirm({ select = true }),
|
||||
|
||||
-- Manually trigger a completion from nvim-cmp.
|
||||
-- Generally you don't need this, because nvim-cmp will display
|
||||
-- completions whenever it has completion options available.
|
||||
["<C-Space>"] = cmp.mapping.complete({}),
|
||||
["<leader>j"] = cmp.mapping(function()
|
||||
if luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<leader>k"] = cmp.mapping(function()
|
||||
if luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
@ -562,6 +620,15 @@ require("lazy").setup({
|
||||
},
|
||||
})
|
||||
end,
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
local luasnip = require("luasnip")
|
||||
if not luasnip then
|
||||
return
|
||||
end
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
},
|
||||
|
||||
{ -- You can easily change to a different colorscheme.
|
||||
@ -587,7 +654,31 @@ require("lazy").setup({
|
||||
-- and try some other statusline plugin
|
||||
"echasnovski/mini.nvim",
|
||||
config = function()
|
||||
require("mini.statusline").setup()
|
||||
require("mini.statusline").setup({
|
||||
content = {
|
||||
active = function()
|
||||
local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 })
|
||||
local git = MiniStatusline.section_git({ trunc_width = 75 })
|
||||
local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 })
|
||||
local filename = MiniStatusline.section_filename({ trunc_width = 140 })
|
||||
local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 })
|
||||
local location = MiniStatusline.section_location({ trunc_width = 75 })
|
||||
local search = MiniStatusline.section_searchcount({ trunc_width = 75 })
|
||||
local words = getWords()
|
||||
return MiniStatusline.combine_groups({
|
||||
|
||||
{ hl = mode_hl, strings = { mode } },
|
||||
{ hl = "MiniStatuslineDevinfo", strings = { git, diagnostics } },
|
||||
"%<", -- Mark general truncate point
|
||||
{ hl = "MiniStatuslineFilename", strings = { filename } },
|
||||
"%=", -- End left alignment
|
||||
{ hl = "MiniStatuslineFileinfo", strings = { fileinfo } },
|
||||
{ hl = "MiniStatuslineFileinfo", strings = { words } },
|
||||
{ hl = mode_hl, strings = { search, location } },
|
||||
})
|
||||
end,
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user