Working on lsp

This commit is contained in:
RingOfStorms (Joshua Bell) 2023-06-12 00:13:14 -05:00
parent cec6b5ba89
commit 42a3ec0172
11 changed files with 127 additions and 25 deletions

View file

@ -1,6 +1,7 @@
{
"LuaSnip": { "branch": "master", "commit": "a13af80734eb28f744de6c875330c9d3c24b5f3b" },
"auto-save.nvim": { "branch": "main", "commit": "979b6c82f60cfa80f4cf437d77446d0ded0addf0" },
"ccc.nvim": { "branch": "main", "commit": "5e85133b895b10f7dc7ce46bdad852c990a3f4b9" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
"cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" },
@ -8,11 +9,13 @@
"glow.nvim": { "branch": "advanced_window", "commit": "bbd0473d72a45094495ee5600b5577823543eefe" },
"lazy.nvim": { "branch": "main", "commit": "d1b02c2dda88422ca573f2a1ebdfb213ce0124d6" },
"lsp-zero.nvim": { "branch": "v2.x", "commit": "8fda9a849d6ab4196ecf129905764ddefdfb64b5" },
"lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "5230617372e656d4a2e1e236e03bf7e7b4b97273" },
"mason.nvim": { "branch": "main", "commit": "7d7efc738e08fc5bee822857db45cb6103f0b0c1" },
"material.nvim": { "branch": "main", "commit": "0c725897bc3d22c45fbf25a602002ee02f06f619" },
"neo-tree.nvim": { "branch": "v2.x", "commit": "20c2f2f5ba083bbb1e37b8bc3d590621434f31e9" },
"nui.nvim": { "branch": "main", "commit": "062e366afcdf2bc1e9d28313a1df4ff14f05cb4e" },
"null-ls.nvim": { "branch": "main", "commit": "a138b14099e9623832027ea12b4631ddd2a49256" },
"nvim-cmp": { "branch": "main", "commit": "b5a636d46c69bb371995c22d7a10ee1544004879" },
"nvim-lspconfig": { "branch": "master", "commit": "0f598b9ab9f2a6d7e137074be99c8d89af44b990" },
"nvim-treesitter": { "branch": "master", "commit": "f2778bd1a28b74adf5b1aa51aa57da85adfa3d16" },

View file

@ -1,7 +1,9 @@
function isEmpty()
return vim.api.nvim_buf_get_name(0) == "" or vim.fn.filereadable(vim.api.nvim_buf_get_name(0)) == 0 or vim.fn.line('$') == 1 and vim.fn.col('$') == 1
end
-- #000000
--
--
vim.api.nvim_create_autocmd({ "VimEnter" }, {
callback = function()
if isEmpty() then
@ -24,3 +26,9 @@ vim.api.nvim_create_autocmd('BufRead', {
pattern = "Dockerfile.*",
command = "set filetype=dockerfile"
})
vim.api.nvim_create_autocmd("BufRead", {
callback = function()
vim.cmd.CccHighlighterEnable()
end,
})

View file

@ -32,7 +32,7 @@ require('util').keymaps({
["<C-k>"] = { "<C-w>k", desc = "Move window above current" },
["<C-l>"] = { "<C-w>l", desc = "Move window right current" },
-- reformat outside of LSP attachment
["<leader>lf"] = { "GVgg=", desc = "Reformat file" }
["<leader>lf"] = { function() vim.lsp.buf.format() end, desc = "Reformat file" }
-- ["<leader>,j"] = { name = " Jest Tests" },

View file

@ -40,3 +40,4 @@ vim.opt.incsearch = true
-- split to the right or below always
vim.opt.splitbelow = true
vim.opt.splitright = true

View file

@ -1,4 +1,6 @@
# Plugins to look into
- https://github.com/lvimuser/lsp-inlayhints.nvim/tree/anticonceal
- https://github.com/theHamsta/nvim-dap-virtual-text/tree/inline-text
- https://github.com/andythigpen/nvim-coverage
- https://github.com/lukas-reineke/indent-blankline.nvim
- https://github.com/johmsalas/text-case.nvim

View file

@ -0,0 +1,7 @@
return {
"uga-rosa/ccc.nvim",
event = "BufRead",
keys = {
{ "<leader>cp", ":CccPick <CR>", desc = "Color Picker" }
},
}

View file

@ -3,32 +3,39 @@ return {
branch = 'v2.x',
dependencies = {
-- LSP Support
{'neovim/nvim-lspconfig'},
{ 'neovim/nvim-lspconfig' },
{
'williamboman/mason.nvim',
build = function()
pcall(vim.cmd, 'MasonUpdate')
end,
},
{'williamboman/mason-lspconfig.nvim'},
{ 'williamboman/mason-lspconfig.nvim' },
-- Autocompletion
{'hrsh7th/nvim-cmp'},
{'hrsh7th/cmp-nvim-lsp'},
{'hrsh7th/cmp-buffer'},
{'hrsh7th/cmp-path'},
{'hrsh7th/cmp-cmdline'},
{ 'hrsh7th/nvim-cmp' },
{ 'hrsh7th/cmp-nvim-lsp' },
{ 'hrsh7th/cmp-buffer' },
{ 'hrsh7th/cmp-path' },
{ 'hrsh7th/cmp-cmdline' },
-- Snips
{'L3MON4D3/LuaSnip'},
{ 'L3MON4D3/LuaSnip' },
},
config = function()
local lsp = require('lsp-zero').preset({})
local config = require 'lspconfig'
local util = require 'lspconfig/util'
local cmp = require 'cmp'
local cmp_action = require('lsp-zero').cmp_action()
lsp.on_attach(function(_, bufnr)
local capabilities = require('cmp_nvim_lsp').default_capabilities()
capabilities = vim.tbl_deep_extend("keep", capabilities, vim.lsp.protocol.make_client_capabilities());
capabilities.textDocument.completion.completionItem.snippetSupport = true
local on_attach = function(_, bufnr)
lsp.default_keymaps({ buffer = bufnr })
end)
end
lsp.on_attach(on_attach)
lsp.ensure_installed({
-- -- https://github.com/williamboman/mason-lspconfig.nvim#available-lsp-servers
"lua_ls",
@ -38,31 +45,44 @@ return {
"cssls",
"cssmodules_ls",
"pyright",
"prettierd",
"html",
"emmet_ls",
"sqlls",
"dockerls",
"docker_compose_language_service",
})
config.lua_ls.setup(lsp.nvim_lua_ls())
config.rust_analyzer.setup {}
config.tsserver.setup {}
config.tsserver.setup {
on_attach = on_attach,
capabilities = capabilities,
root_dir = nvim_lsp.util.root_pattern("tsconfig.json", ".git"),
}
config.eslint.setup {}
config.cssls.setup {}
config.cssmodules_ls.setup {}
config.pyright.setup {}
local cmp = require 'cmp'
local cmp_action = require('lsp-zero').cmp_action()
lsp.setup()
cmp.setup({
window = {
documentation = cmp.config.window.bordered(),
},
sources = {
{ name = "path" },
{ name = "nvim_lsp" },
{ name = "buffer", keyword_length = 3 },
{ name = "luasnip", keyword_length= 2 },
{ name = "nvim_lsp", priority = 1000 },
{ name = "luasnip", priority = 750, keyword_length = 2 },
{ name = "buffer", priority = 500, keyword_length = 3 },
{ name = "path", priority = 250 },
},
mapping = {
['<CR>'] = cmp.mapping.confirm({select = false}),
['<CR>'] = cmp.mapping.confirm({ select = false }),
['<Tab>'] = cmp_action.tab_complete(),
['<S-Tab>'] = cmp_action.select_prev_or_fallback(),
-- Ctrl+Space to trigger completion menu
@ -72,7 +92,6 @@ return {
['<C-b>'] = cmp_action.luasnip_jump_backward(),
}
})
lsp.setup()
end,
-- keys = {
-- { "<leader>l", "<Nop>", desc = "LSP" },

18
lua/plugins/lualine.lua Normal file
View file

@ -0,0 +1,18 @@
return {
"nvim-lualine/lualine.nvim",
opts = {
options = {
theme = "codedark",
section_separators = { left = '', right = '' },
component_separators = '|',
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {'filename'},
lualine_x = {'encoding', 'filetype', 'filesize'},
lualine_y = {'searchcount', 'selectioncount'},
lualine_z = {'location'},
},
}
}

46
lua/plugins/null-ls.lua Normal file
View file

@ -0,0 +1,46 @@
-- npm install -g cspell@latest
local output = vim.fn.system {
"which",
"cspell",
}
if output == nil or output == "" then
-- if v:shell_error != 0 then
vim.fn.system {
"npm",
"install",
"-g",
"cspell@latest",
}
end
return {
"jose-elias-alvarez/null-ls.nvim",
opts = function(_, config)
-- config variable is the default definitions table for the setup function call
local null_ls = require "null-ls"
-- Check supported formatters and linters
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
config.sources = {
-- Set a formatter
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.prettier,
null_ls.builtins.formatting.rustfmt,
-- null_ls.builtins.code_actions.proselint, -- TODO looks interesting
null_ls.builtins.code_actions.cspell.with {
config = {
find_json = function() return vim.fn.findfile("cspell.json", vim.fn.environ().HOME .. "/.config/nvim/lua/user/;") end,
},
},
null_ls.builtins.diagnostics.cspell.with {
extra_args = { "--config", "~/.config/nvim/lua/user/cspell.json" },
},
}
config.update_in_insert = true
return config
end,
}

View file

@ -53,6 +53,7 @@ return {
"terraform",
"toml",
"tsx",
"jsx",
"typescript",
"vue",
"yaml",
@ -60,7 +61,7 @@ return {
auto_install = true,
highlight = {
enable = true,
disable = function(_, bufnr) return vim.api.nvim_buf_line_count(bufnr) > 10000 end,
-- disable = function(_, bufnr) return vim.api.nvim_buf_line_count(bufnr) > 10000 end,
additional_vim_regex_highlighting = false,
},
incremental_selection = { enable = true },

View file

@ -1,3 +0,0 @@
return {
"jose-elias-alvarez/null-ls.nvim",
}