chore(nvim): tweaks, docs, updates

This commit is contained in:
2023-09-13 10:29:05 +03:00
parent 0c0f3823e4
commit 2df27d2a0e
11 changed files with 143 additions and 218 deletions

View File

@@ -1,12 +1,7 @@
-- To be used anywhere.
local function job(command) vim.api.nvim_command("call jobstart('" .. command .. "')") end
-- luacheck: globals vim
local function format()
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = "<buffer>",
callback = function() vim.lsp.buf.format() end,
})
end
-- To be used anywhere.
-- local function job(command) vim.api.nvim_command("call jobstart('" .. command .. "')") end
local function yaml_ft(path, bufnr)
-- get content of buffer as string
@@ -45,7 +40,7 @@ vim.filetype.add({
csv = "csv",
cl = "opencl",
env = "env",
sh = "zsh",
sh = "bash",
--
},
pattern = {
@@ -54,10 +49,10 @@ vim.filetype.add({
-- [".*config/nvim/.*"] = function() vim.api.nvim_command "cd ~/.config/nvim/" end,
---- Typescript Projects
[".*/src/.*ts"] = function() format() end,
[".*/src/.*json"] = function() format() end,
[".*/src/.*scss"] = function() format() end,
[".*/src/.*html"] = function() format() end,
-- [".*/src/.*ts"] = function() format() end,
-- [".*/src/.*json"] = function() format() end,
-- [".*/src/.*scss"] = function() format() end,
-- [".*/src/.*html"] = function() format() end,
--[".*Code/ivuorinen/[project]/src/.*ts"] = function()
-- vim.api.nvim_command('cd ~/Code/ivuorinen/[project]/')
@@ -73,5 +68,6 @@ vim.filetype.add({
["tsconfig.json"] = "json5",
[".ignore"] = "gitignore",
["docker-compose.yml"] = "yaml.docker-compose",
},
})

View File

@@ -21,7 +21,7 @@ wk.register({
name = "+buffer",
n = { "<cmd>tabnew<cr>", "[n]ew tab" },
a = {
name = "+annotate"
name = "+annotate",
-- defined in plugins/neogen.lua
},
c = {

View File

@@ -6,18 +6,20 @@ CAPABILITIES.textDocument.completion.completionItem.snippetSupport = true
-- [[ Configure LSP ]]
-- This function gets run when an LSP connects to a particular buffer.
local on_attach = function(_, bufnr)
local on_attach = function(client, bufnr)
local nmap = function(keys, func, desc)
if desc then desc = "LSP: " .. desc end
vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc })
end
if client.server_capabilities.documentSymbolProvider then require("nvim-navic").attach(client, bufnr) end
local wk = require("which-key")
wk.register({
l = {
name = "LSP",
name = "+lsp",
n = { vim.lsp.buf.rename, "Rename" },
c = { vim.lsp.buf.code_action, "Code Action" },
f = { "<cmd>Format", "Format current buffer with LSP" },
@@ -33,7 +35,7 @@ local on_attach = function(_, bufnr)
},
},
g = {
name = "Goto",
name = "+goto",
d = { vim.lsp.buf.definition, "[G]oto [D]efinition" },
r = { require("telescope.builtin").lsp_references, "[G]oto [R]eferences" },
I = { vim.lsp.buf.implementation, "[G]oto [I]mplementation" },
@@ -48,12 +50,12 @@ local on_attach = function(_, bufnr)
nmap("<C-k>", vim.lsp.buf.signature_help, "Signature Documentation")
-- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(
bufnr,
"Format",
function(_) vim.lsp.buf.format() end,
{ desc = "Format current buffer with LSP" }
)
-- vim.api.nvim_buf_create_user_command(
-- bufnr,
-- "Format",
-- function(_) vim.lsp.buf.format() end,
-- { desc = "Format current buffer with LSP" }
-- )
end
-- Enable the following language servers
@@ -71,13 +73,38 @@ local servers = {
ansiblels = {},
bashls = {},
clangd = {},
cssls = {
cmd = { "vscode-css-language-server", "--stdio" },
filetypes = { "css", "scss", "less" },
-- root_dir = root_pattern("package.json", ".git") or bufdir,
settings = {
css = {
validate = true,
},
less = {
validate = true,
},
scss = {
validate = true,
},
},
single_file_support = true,
capabilities = CAPABILITIES,
},
diagnosticls = {},
docker_compose_language_service = {},
dockerls = {},
eslint = {},
gopls = {},
eslint = {}, -- JS
gopls = {}, -- Go
graphql = {},
html = { filetypes = { "html", "twig", "hbs" } },
intelephense = {},
jsonls = {},
intelephense = {}, -- PHP
jsonls = {
json = {
schemas = require("schemastore").json.schemas(),
validate = { enable = true },
},
},
lua_ls = {
Lua = {
diagnostics = { globals = { "vim" } },
@@ -85,115 +112,33 @@ local servers = {
telemetry = { enable = false },
},
},
marksman = {},
pyright = {},
rust_analyzer = {},
terraformls = {},
tsserver = {},
vuels = {},
yamlls = {},
marksman = {}, -- Markdown
psalm = {}, -- PHP
pylsp = {}, -- Python
pyright = {}, -- Python
rust_analyzer = {}, -- Rust
terraformls = {}, -- Terraform
tsserver = {}, -- TypeScript
vuels = {}, -- Vue
yamlls = { -- YAML
yaml = {
schemaStore = {
-- You must disable built-in schemaStore support if you want to use
-- this plugin and its advanced options like `ignore`.
enable = false,
-- Avoid TypeError: Cannot read properties of undefined (reading 'length')
url = "",
},
schemas = require("schemastore").yaml.schemas(),
},
},
}
-- Setup neovim lua configuration
require("neodev").setup()
-- nvim-cmp supports additional completion capabilities,
-- so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities()
-- Ensure the servers above are installed
local mason_lspconfig = require("mason-lspconfig")
mason_lspconfig.setup({
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = vim.tbl_keys(servers),
automatic_installation = true,
automatic_installtion = true,
})
mason_lspconfig.setup_handlers({
function(server_name)
require("lspconfig")[server_name].setup({
capabilities = capabilities,
on_attach = on_attach,
settings = servers[server_name],
filetypes = (servers[server_name] or {}).filetypes,
})
end,
})
-- Configure language servers for specific languages
local lspconfig = require("lspconfig")
-- Bash Language Server
lspconfig.bashls.setup({
cmd = {
"bash-language-server",
"start",
},
filetypes = { "sh", "zsh" },
capabilities = CAPABILITIES,
})
-- HTML
lspconfig.html.setup({ capabilities = CAPABILITIES })
-- JSON
lspconfig.jsonls.setup({
settings = {
json = {
schemas = require("schemastore").json.schemas(),
validate = { enable = true },
},
},
capabilities = CAPABILITIES,
})
-- Python
lspconfig.pylsp.setup({})
-- CSS + Less + SCSS
lspconfig.cssls.setup({
cmd = { "vscode-css-language-server", "--stdio" },
filetypes = { "css", "scss", "less" },
-- root_dir = root_pattern("package.json", ".git") or bufdir,
settings = {
css = {
validate = true,
},
less = {
validate = true,
},
scss = {
validate = true,
},
},
single_file_support = true,
capabilities = CAPABILITIES,
on_attach = function(client, bufnr)
if client.server_capabilities.documentSymbolProvider then require("nvim-navic").attach(client, bufnr) end
end,
})
-- rome
local util = require("lspconfig.util")
lspconfig.rome.setup({
root_dir = util.root_pattern("rome.json"),
single_file_support = true,
on_attach = function(client, bufnr)
if client.server_capabilities.documentSymbolProvider then require("nvim-navic").attach(client, bufnr) end
end,
capabilities = CAPABILITIES,
})
-- Typescript + Javascript
lspconfig.tsserver.setup({
capabilities = CAPABILITIES,
on_attach = function(client, bufnr)
if client.server_capabilities.documentSymbolProvider then require("nvim-navic").attach(client, bufnr) end
end,
})
lspconfig.lua_ls.setup({})
lspconfig.yamlls.setup({})

View File

@@ -1,74 +1,65 @@
-- luacheck: globals vim
local vim = vim
-- Use the new FileType system of Neovim.
-- let g:do_filetype_lua = 1
vim.g.do_filetype_lua = 1
vim.wo.linebreak = true -- Fix moving through lines 'gk' and 'gj'
vim.o.breakindent = true -- Enable break indent
vim.o.undofile = true -- Save undo history
vim.wo.number = true -- Show lines number (hybrid)
vim.wo.linebreak = true -- Fix moving through lines 'gk' and 'gj'
vim.o.breakindent = true -- Enable break indent
vim.o.undofile = true -- Save undo history
vim.wo.number = true -- Show lines number (hybrid)
vim.wo.relativenumber = true -- Show lines number (hybrid)
vim.wo.signcolumn = "yes" -- Keep signcolumn on by default
vim.wo.signcolumn = "yes" -- Keep signcolumn on by default
vim.o.laststatus = 3 -- Global statusline.
vim.o.cmdheight = 0 -- To have a extra line :)
vim.wo.wrap = true -- Set wrap for words
vim.o.showtabline = 2 -- Always show tabs
vim.o.list = true -- Show xtra spaces
vim.o.wildmenu = true -- Set wildmenu for later use
vim.o.hlsearch = true -- Highlighting search
vim.o.ruler = true -- Set ruler for better look
vim.o.hidden = true -- No nice message
vim.o.showcmd = true -- Partial commands only in the screen
vim.o.showmatch = true -- Match braces when inserting new ones
vim.opt.backup = false -- No backups because some plugins freak out
vim.opt.writebackup = false -- No backups because some plugins freak out
vim.o.scrolloff = 40 -- Off scroll when moving through the buffer
vim.go.termguicolors = true -- For terminal RGB colours
vim.go.t_Co = "256" -- Colours, I believe
vim.go.t_ut = "" -- Colours, I believe
vim.o.laststatus = 3 -- Space for tabs
vim.o.softtabstop = 2 -- Space for tabs
vim.o.expandtab = true -- Expand tab to use spaces instead
vim.o.tabstop = 2 -- Space for tabs
vim.bo.shiftwidth = 2 -- Space for tabs
vim.o.shiftwidth = 2 -- Space for tabs
vim.o.formatoptions = "tqj" -- Format options to not create new lines with comments
vim.o.mouse = "a" -- Mouse working with neovim
-- Case-insensitive searching UNLESS \C or capital in search
vim.o.ignorecase = true
vim.o.smartcase = true
vim.o.cmdheight = 0 -- To have a extra line :)
vim.wo.wrap = true -- Set wrap for words
vim.o.showtabline = 2 -- Always show tabs
vim.opt.list = true -- Show xtra spaces
vim.o.wildmenu = true -- Set wildmenu for later use
vim.o.hlsearch = true -- Highlighting search
vim.o.ruler = true -- Set ruler for better look
vim.o.hidden = true -- No nice message
vim.o.showcmd = true -- Partial commands only in the screen
vim.o.showmatch = true -- Match braces when inserting new ones
-- Cursor line
---- Cursor column
vim.o.cursorline = true
vim.wo.cursorline = true
vim.o.cursorcolumn = true
vim.wo.cursorcolumn = true
vim.o.scrolloff = 40 -- Off scroll when moving through the buffer
vim.go.termguicolors = true -- For terminal RGB colours
vim.go.t_Co = "256" -- Colours, I believe
vim.go.t_ut = "" -- Colours, I believe
vim.o.laststatus = 3 -- Space for tabs
vim.o.softtabstop = 2 -- Space for tabs
vim.o.expandtab = true -- Expand tab to use spaces instead
vim.o.tabstop = 2 -- Space for tabs
vim.bo.shiftwidth = 2 -- Space for tabs
vim.o.shiftwidth = 2 -- Space for tabs
vim.o.formatoptions = "tqj" -- Format options to not create new lines with comments
vim.o.mouse = "a" -- Mouse working with neovim
-- viminfo file
-- vim.o.viminfo = vim.o.viminfo .. '~/.config/nvim/viminfo'
-- Spell language to English (UK)
vim.o.spelllang = "en_gb"
vim.bo.spelllang = "en_gb"
vim.opt.laststatus = 2 -- Global statusline.
-- When "on" the commands listed below move the cursor to the first non-blank
-- of the line. When off the cursor is kept in the same column (if possible).
-- https://neovim.io/doc/user/options.html#'startofline'
vim.opt.startofline = true
-- Set path for better searching across the system
-- vim.o.path = vim.o.path .. '**'
vim.o.startofline = true
-- Complete options
vim.o.completeopt = "menuone,longest,noselect"
vim.o.shortmess = vim.o.shortmess .. "c"
vim.go.pumblend = 10 -- Menu Transparency.
-- ╭──────────────────────────────────────────────────────────╮
-- │ Variables │
-- ╰──────────────────────────────────────────────────────────╯
@@ -87,9 +78,6 @@ vim.api.nvim_set_option("title", true)
-- Set clipboard to be global across the system
vim.api.nvim_set_option("clipboard", "unnamedplus")
-- Basic fold column
vim.api.nvim_set_option("foldcolumn", "1")
-- Set dictionary to language spell
vim.api.nvim_set_option("dictionary", "/usr/share/dict/words")
@@ -101,5 +89,6 @@ vim.api.nvim_set_option(
-- Folding
vim.api.nvim_set_option("foldmethod", "syntax")
vim.api.nvim_set_option('foldenable', false)
vim.api.nvim_set_option('foldminlines', 5)
vim.api.nvim_set_option("foldenable", false)
vim.api.nvim_set_option("foldminlines", 5)
vim.api.nvim_set_option("foldcolumn", "1")

View File

@@ -5,10 +5,10 @@ return {
dependencies = {
"neovim/nvim-lspconfig",
"SmiteshP/nvim-navic",
"kyazdani42/nvim-web-devicons",
"nvim-tree/nvim-web-devicons",
},
version = "*",
config = {
opts = {
theme = "catppuccin",
-- If you set this to false, floating windows will look weird

View File

@@ -4,7 +4,7 @@
return {
"lewis6991/gitsigns.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
config = {
opts = {
signs = {
add = { hl = "GitSignsAdd", text = "", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" },
change = { hl = "GitSignsChange", text = "", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" },

View File

@@ -1,14 +1,15 @@
-- luacheck: globals vim
local vim = vim
return {
-- plenary: full; complete; entire; absolute; unqualified.
-- All the lua functions I don't want to write twice.
-- https://github.com/nvim-lua/plenary.nvim
{ "nvim-lua/plenary.nvim", lazy = true },
{ "nvim-lua/plenary.nvim", lazy = true },
-- lua `fork` of vim-web-devicons for neovim
-- https://github.com/nvim-tree/nvim-web-devicons
{ "kyazdani42/nvim-web-devicons" },
{ "nvim-tree/nvim-web-devicons" },
-- The theme of choise, catppuccin
-- https://github.com/catppuccin/nvim
@@ -38,6 +39,7 @@ return {
},
cmp = true,
dap = { enabled = true, enable_ui = true },
fidget = true,
gitsigns = true,
harpoon = true,
indent_blankline = {
@@ -45,6 +47,7 @@ return {
colored_indent_levels = false,
},
mason = true,
mini = true,
neotree = true,
notify = true,
native_lsp = {
@@ -185,21 +188,17 @@ return {
-- A neovim lua plugin to help easily manage multiple terminal windows
-- https://github.com/akinsho/toggleterm.nvim
{
'akinsho/toggleterm.nvim',
"akinsho/toggleterm.nvim",
version = "*",
opts = {
open_mapping = [[<c-t>]],
insert_mappings = true,
-- direction = "float",
float_opts = {
width = function()
return math.floor(vim.o.columns * 0.9)
end,
height = function()
return math.floor(vim.o.lines * 0.9)
end,
width = function() return math.floor(vim.o.columns * 0.9) end,
height = function() return math.floor(vim.o.lines * 0.9) end,
},
}
},
},
-- Close buffer without messing up with the window.
@@ -210,7 +209,7 @@ return {
-- https://github.com/kazhala/close-buffers.nvim
{ "kazhala/close-buffers.nvim" },
-- JSONLS
-- JSON schemas for Neovim
-- https://github.com/b0o/schemastore.nvim
{ "b0o/schemastore.nvim" },
@@ -226,7 +225,7 @@ return {
-- https://github.com/bennypowers/nvim-regexplainer
{
"bennypowers/nvim-regexplainer",
requires = {
dependencies = {
"nvim-treesitter/nvim-treesitter",
"MunifTanjim/nui.nvim",
},
@@ -256,9 +255,5 @@ return {
-- Vim plugin for automatic time tracking and metrics generated from your programming activity.
-- https://github.com/wakatime/vim-wakatime
{
"wakatime/vim-wakatime",
lazy = false,
enabled = true,
},
{ "wakatime/vim-wakatime", lazy = false, enabled = true },
}

View File

@@ -9,7 +9,7 @@ return {
"nvim-neo-tree/neo-tree.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"kyazdani42/nvim-web-devicons",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
{
-- only needed if you want to use the commands with "_with_window_picker" suffix

View File

@@ -4,8 +4,8 @@
-- https://github.com/folke/trouble.nvim
return {
"folke/trouble.nvim",
dependencies = "kyazdani42/nvim-web-devicons",
config = {
dependencies = "nvim-tree/nvim-web-devicons",
opts = {
-- position of the list can be: bottom, top, left, right
position = "bottom",
-- height of the trouble list when position is top or bottom

View File

@@ -3,7 +3,7 @@
-- https://github.com/folke/twilight.nvim
return {
"folke/twilight.nvim",
config = {
opts = {
dimming = {
-- amount of dimming
alpha = 0.2,