Working on lsp

This commit is contained in:
RingOfStorms (Joshua Bell) 2023-06-09 03:50:20 -05:00
parent 764b890c58
commit 2566fbbec4
18 changed files with 293 additions and 110 deletions

View file

@ -1,7 +1,6 @@
require "options"
require "keymaps"
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
local output = vim.fn.system({
@ -27,5 +26,4 @@ require("lazy").setup("plugins", {
vim.cmd 'colorscheme material'
require "tools"
require "autocommands"
require "lsp"

View file

@ -1,17 +1,20 @@
{
"LuaSnip": { "branch": "master", "commit": "51ebb4b6637290e1b8e0fb0d6f38b605d3c24940" },
"LuaSnip": { "branch": "master", "commit": "a13af80734eb28f744de6c875330c9d3c24b5f3b" },
"auto-save.nvim": { "branch": "main", "commit": "979b6c82f60cfa80f4cf437d77446d0ded0addf0" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
"cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"glow.nvim": { "branch": "advanced_window", "commit": "bbd0473d72a45094495ee5600b5577823543eefe" },
"lazy.nvim": { "branch": "main", "commit": "ae25448d39fb2bdc38a139339233270edec44484" },
"lazy.nvim": { "branch": "main", "commit": "d1b02c2dda88422ca573f2a1ebdfb213ce0124d6" },
"lsp-zero.nvim": { "branch": "v2.x", "commit": "8fda9a849d6ab4196ecf129905764ddefdfb64b5" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "c55d18f3947562e699d34d89681edbf9f0e250d3" },
"mason.nvim": { "branch": "main", "commit": "08b2fd308e0107eab9f0b59d570b69089fd0b522" },
"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": "d5a82aae64426a805e19d8ef5a379292f9dc55d3" },
"nvim-cmp": { "branch": "main", "commit": "fc0f694af1a742ada77e5b1c91ff405c746f4a26" },
"nvim-lspconfig": { "branch": "master", "commit": "1c13e529bd5683b54a39b633a560d2f00fcb25af" },
"nui.nvim": { "branch": "main", "commit": "062e366afcdf2bc1e9d28313a1df4ff14f05cb4e" },
"nvim-cmp": { "branch": "main", "commit": "b5a636d46c69bb371995c22d7a10ee1544004879" },
"nvim-lspconfig": { "branch": "master", "commit": "0f598b9ab9f2a6d7e137074be99c8d89af44b990" },
"nvim-treesitter": { "branch": "master", "commit": "f2778bd1a28b74adf5b1aa51aa57da85adfa3d16" },
"nvim-ts-autotag": { "branch": "main", "commit": "40615e96075c743ef47aaf9de966dc348bec6459" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "0bf8fbc2ca8f8cdb6efbd0a9e32740d7a991e4c3" },
@ -20,7 +23,5 @@
"rest.nvim": { "branch": "main", "commit": "d8dc204e9f6fd930d9d1d709f0d19138f804431a" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" },
"telescope.nvim": { "branch": "master", "commit": "c1a2af0af69e80e14e6b226d3957a064cd080805" },
"undotree": { "branch": "master", "commit": "485f01efde4e22cb1ce547b9e8c9238f36566f21" },
"vim-autoswap": { "branch": "master", "commit": "e587e4b14a605d8921942ba65a37583813289272" },
"which-key.nvim": { "branch": "main", "commit": "e271c28118998c93a14d189af3395812a1aa646c" }
"undotree": { "branch": "master", "commit": "485f01efde4e22cb1ce547b9e8c9238f36566f21" }
}

View file

@ -1 +1,26 @@
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
vim.api.nvim_create_autocmd({ "VimEnter" }, {
callback = function()
if isEmpty() then
require('telescope.builtin').find_files()
end
end
})
vim.api.nvim_create_autocmd('BufRead', {
pattern = ".env*",
command = "set filetype=sh"
})
vim.api.nvim_create_autocmd('BufRead', {
pattern = ".*rc",
command = "set filetype=sh"
})
vim.api.nvim_create_autocmd('BufRead', {
pattern = "Dockerfile.*",
command = "set filetype=dockerfile"
})

View file

@ -11,51 +11,61 @@ vim.g.mapleader = " "
-- command_mode = "c",
require('util').keymaps({
n = {
n = {
["n"] = { "nzzzv", desc = "Next search result centered" },
["N"] = { "Nzzzv", desc = "Previous search result centered" },
["<esc>"] = { ":noh<CR><esc>", desc = "Clear search on escape" },
["<return>"] = {":noh<CR><return>", desc = "Clear search on return" },
["<leader>w"] = { "<cmd>w<cr>", desc = "Save" },
["<leader>q"] = { "<cmd>confirm q<cr>", desc = "Quit" },
["|"] = { "<cmd>vsplit<cr>", desc = "Vertical Split" },
["\\"] = { "<cmd>split<cr>", desc = "Horizontal Split" },
["<C-d>"] = { "<C-d>zz", desc = "Vertical half page down and center cursor" },
["<C-u>"] = { "<C-u>zz", desc = "Vertical half page up and center cursor" },
["y"] = { '"*y', desc = "Copy to system clipboard" },
["p"] = { '"*p', desc = "Paste from system clipboard" },
["<leader>Q"] = { ":qa<CR>", desc = "Quit all" },
["<leader>w"] = { "<cmd>w<cr>", desc = "Save" },
["<leader>q"] = { "<cmd>confirm q<cr>", desc = "Quit" },
["|"] = { "<cmd>vsplit<cr>", desc = "Vertical Split" },
["\\"] = { "<cmd>split<cr>", desc = "Horizontal Split" },
["<C-d>"] = { "<C-d>zz", desc = "Vertical half page down and center cursor" },
["<C-u>"] = { "<C-u>zz", desc = "Vertical half page up and center cursor" },
["<leader>y"] = { '"*y', desc = "Copy to system clipboard" },
["<Leader>p"] = { '"*p', desc = "Paste from system clipboard" },
["<leader>Q"] = { ":qa<CR>", desc = "Quit all" },
["J"] = { "mzJ`z", desc = "Move line below onto this line" },
-- window navigation
["<C-h>"] = { "<C-w>h", desc = "Move window left current" },
["<C-j>"] = { "<C-w>j", desc = "Move window below current" },
["<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>,j"] = { name = " Jest Tests" },
-- ["<leader>,jr"] = { function() require("jester").run() end, desc = "Run test under cursor" },
-- ["<leader>,jf"] = { function() require("jester").run_file() end, desc = "Run tests for file" },
-- ["<leader>,jl"] = { function() require("jester").run_last() end, desc = "Run last ran test" },
-- ["<leader>lz"] = { ":LspRestart<CR>", desc = "Restart LSP Server" },
},
v = {
["y"] = { '"*y', desc = "Copy to system clipboard" },
["p"] = { '"*p', desc = "Paste from system clipboard" },
-- ["<leader>,j"] = { name = " Jest Tests" },
-- ["<leader>,jr"] = { function() require("jester").run() end, desc = "Run test under cursor" },
-- ["<leader>,jf"] = { function() require("jester").run_file() end, desc = "Run tests for file" },
-- ["<leader>,jl"] = { function() require("jester").run_last() end, desc = "Run last ran test" },
-- ["<leader>lz"] = { ":LspRestart<CR>", desc = "Restart LSP Server" },
},
v = {
["y"] = { '"*y', desc = "Copy to system clipboard" },
["p"] = { '"*p', desc = "Paste from system clipboard" },
["J"] = { ":m '>+1<CR>gv=gv", desc = "Visually move block down"},
["K"] = { ":m '<-2<CR>gv=gv", desc = "Visually move block up"},
},
i = {
["<C-k>"] = { "<Up>", desc = "Up" },
["<C-j>"] = { "<Down>", desc = "Down" },
["<C-h>"] = { "<Left>", desc = "Left" },
["<C-l>"] = { "<Right>", desc = "Right" },
["<C-4>"] = { "<End>", desc = "End" },
["<C-6>"] = { "<Home>", desc = "Home" },
},
c = {
["<C-h>"] = { "<Left>", desc = "Left" },
["<C-j>"] = { "<Down>", desc = "Down" },
["<C-k>"] = { "<Up>", desc = "Up" },
["<C-l>"] = { "<Right>", desc = "Right" },
["<C-4>"] = { "<End>", desc = "End" },
["<C-6>"] = { "<Home>", desc = "Home" },
},
},
i = {
["<C-k>"] = { "<Up>", desc = "Up" },
["<C-j>"] = { "<Down>", desc = "Down" },
["<C-h>"] = { "<Left>", desc = "Left" },
["<C-l>"] = { "<Right>", desc = "Right" },
["<C-4>"] = { "<End>", desc = "End" },
["<C-6>"] = { "<Home>", desc = "Home" },
},
c = {
["<C-h>"] = { "<Left>", desc = "Left" },
["<C-j>"] = { "<Down>", desc = "Down" },
["<C-k>"] = { "<Up>", desc = "Up" },
["<C-l>"] = { "<Right>", desc = "Right" },
["<C-4>"] = { "<End>", desc = "End" },
["<C-6>"] = { "<Home>", desc = "Home" },
},
x = {
["<leader>p"] = { '"_dP', desc = "Paste w/o copying replaced content" },
["<C-r"] = {'"hy:%s/<C-r>h//g<left><left>', desc = "Replace current selection"},
},
})

View file

@ -1,21 +0,0 @@
local lsp = require('lsp-zero').preset({})
lsp.on_attach(function(client, bufnr)
lsp.default_keymaps({buffer = bufnr})
end)
lsp.ensure_installed({
"tsserver",
"eslint",
"lua_ls",
"rust_analyzer",
"cssls",
"cssmodules_ls",
"pyright",
})
-- (Optional) Configure lua language server for neovim
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls())
lsp.setup()

View file

@ -1,5 +1,5 @@
-- allow use of system keyboard
vim.opt.clipboard = "unnamedplus"
-- vim.opt.clipboard = "unnamedplus"
-- allow use of mouse
vim.opt.mouse = 'a'

View file

@ -12,4 +12,6 @@
["<leader>,ck"] = { ":Kebab<CR>", desc = "To Kebab Case" },
["<leader>,ce"] = { ":Screm<CR>", desc = "To Screm Case" },
- https://github.com/tpope/vim-fugitive
- https://github.com/folke/noice.nvim
- greg's: https://github.com/gblock0/dotfiles/blob/master/nvim/.config/nvim/lua/gb/plugins.lua
- others: https://nvimluau.dev/

View file

@ -4,6 +4,6 @@ return {
event = "BufEnter *.http",
requires = { "nvim-lua/plenary.nvim" },
keys = {
{ "<leader>r", function() require("rest-nvim").run() end, desc = "Send http request" }
{ "<leader>r", function() require("rest-nvim").run() end, desc = "Send selected http request" }
}
}

View file

@ -1,20 +1,80 @@
return {
'VonHeikemen/lsp-zero.nvim',
branch = 'v2.x',
dependencies = {
-- LSP Support
{'neovim/nvim-lspconfig'}, -- Required
{ -- Optional
'williamboman/mason.nvim',
build = function()
pcall(vim.cmd, 'MasonUpdate')
end,
},
{'williamboman/mason-lspconfig.nvim'}, -- Optional
'VonHeikemen/lsp-zero.nvim',
branch = 'v2.x',
dependencies = {
-- LSP Support
{'neovim/nvim-lspconfig'},
{
'williamboman/mason.nvim',
build = function()
pcall(vim.cmd, 'MasonUpdate')
end,
},
{'williamboman/mason-lspconfig.nvim'},
-- Autocompletion
{'hrsh7th/nvim-cmp'},
{'hrsh7th/cmp-nvim-lsp'},
{'hrsh7th/cmp-buffer'},
{'hrsh7th/cmp-path'},
{'hrsh7th/cmp-cmdline'},
-- Snips
{'L3MON4D3/LuaSnip'},
},
config = function()
local lsp = require('lsp-zero').preset({})
local config = require 'lspconfig'
local util = require 'lspconfig/util'
-- Autocompletion
{'hrsh7th/nvim-cmp'}, -- Required
{'hrsh7th/cmp-nvim-lsp'}, -- Required
{'L3MON4D3/LuaSnip'}, -- Required
},
lsp.on_attach(function(_, bufnr)
lsp.default_keymaps({ buffer = bufnr })
end)
lsp.ensure_installed({
-- -- https://github.com/williamboman/mason-lspconfig.nvim#available-lsp-servers
"lua_ls",
"rust_analyzer",
"tsserver",
"eslint",
"cssls",
"cssmodules_ls",
"pyright",
})
config.lua_ls.setup(lsp.nvim_lua_ls())
config.rust_analyzer.setup {}
config.tsserver.setup {}
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()
cmp.setup({
sources = {
{ name = "path" },
{ name = "nvim_lsp" },
{ name = "buffer", keyword_length = 3 },
{ name = "luasnip", keyword_length= 2 },
},
mapping = {
['<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
['<C-Space>'] = cmp.mapping.complete(),
['<C-f>'] = cmp_action.luasnip_jump_forward(),
['<C-b>'] = cmp_action.luasnip_jump_backward(),
}
})
lsp.setup()
end,
-- keys = {
-- { "<leader>l", "<Nop>", desc = "LSP" },
-- },
}

View file

@ -1,18 +1,32 @@
return {
"nvim-telescope/telescope.nvim",
tag = '0.1.1',
dependencies = {
{ "nvim-lua/plenary.nvim" },
{ "nvim-telescope/telescope-fzf-native.nvim", enabled = vim.fn.executable "make" == 1, build = "make" },
},
cmd = "Telescope",
keys = {
{ "<leader>f", "<Nop>", desc = "Find ..." },
{ "<leader>ff", function() require('telescope.builtin').find_files() end, desc = "Find Files" },
{ "<leader>fg", function() require('telescope.builtin').git_files() end, desc = "Find Git only Files" },
{ "<leader>fw", function() require('telescope.builtin').live_grep() end, desc = "Find Words" },
{ "<leader>fc", function() require('telescope.builtin').commands() end, desc = "Find Commands" },
{ "<leader>fk", function() require('telescope.builtin').keymaps() end, desc = "Find Commands" },
},
opts = {},
"nvim-telescope/telescope.nvim",
tag = '0.1.1',
dependencies = {
{ "nvim-lua/plenary.nvim" },
{ "nvim-telescope/telescope-fzf-native.nvim", enabled = vim.fn.executable "make" == 1, build = "make" },
},
cmd = "Telescope",
keys = {
{ "<leader>f", "<Nop>", desc = "Find ..." },
{ "<leader>ff", function() require('telescope.builtin').find_files() end, desc = "Find Files" },
{ "<leader>fg", function() require('telescope.builtin').git_files() end, desc = "Find Git only Files" },
{ "<leader>fw", function() require('telescope.builtin').live_grep() end, desc = "Find Words" },
{ "<leader>fc", function() require('telescope.builtin').commands() end, desc = "Find Commands" },
{ "<leader>fk", function() require('telescope.builtin').keymaps() end, desc = "Find Commands" },
{ "<leader>fb", function() require('telescope.builtin').buffers() end, desc = "Find Commands" },
},
opts = {
defaults = {
vimgrep_arguments = {
"rg",
"-L",
"--color=never",
"--no-heading",
"--with-filename",
"--line-number",
"--column",
"--smart-case",
}
}
},
}

View file

@ -22,6 +22,7 @@ return {
opts = {
-- "all",
ensure_installed = {
"lua",
"http",
"json",
"bash",
@ -43,16 +44,12 @@ return {
"markdown",
"markdown_inline",
"nix",
"passwd",
"prisma",
"proto",
"python",
"regex",
"rst",
"rust",
"scss",
"sql",
"svelte",
"terraform",
"toml",
"tsx",

View file

@ -0,0 +1,19 @@
return {
{
"hrsh7th/nvim-cmp",
dependencies = {
{
"hrsh7th/cmp-cmdline",
},
{
"hrsh7th/cmp-path",
},
{
"hrsh7th/cmp-buffer",
},
{
"hrsh7th/cmp-nvim-lsp",
},
}
},
}

View file

@ -0,0 +1,75 @@
return {
{
-- Mason: install and manage LSP servers, DAP servers, linters, and formatters
"williamboman/mason.nvim",
build = ":MasonUpdate", -- :MasonUpdate updates registry contents
},
{
"williamboman/mason-lspconfig.nvim",
opts = {
-- Available servers: https://github.com/williamboman/mason-lspconfig.nvim#available-lsp-servers
ensure_installed = {
'lua_ls',
'rust_analyzer',
'tsserver',
"eslint",
'cssls',
'cssmodules_ls',
'pyright',
},
},
},
{
"neovim/nvim-lspconfig",
config = function(_, opts)
local c = require 'lspconfig'
local u = require "lspconfig/util"
c.lua_ls.setup {
workspace = {
library = {
[vim.fn.expand "$VIMRUNTIME/lua"] = true,
[vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
[vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true,
},
},
settings = {
Lua = {
diagnostics = {
globals = { "vim" }
}
}
}
}
c.rust_analyzer.setup {
on_attach = function() end,
capabilities = {},
filetypes = { "rust" },
root_dir = u.root_pattern("Cargo.toml"),
settings = {
["rust-analyzer"] = {
cargo = {
allFeatures = true,
},
},
},
}
c.tsserver.setup {
}
c.eslint.setup {
}
c.cssls.setup {}
c.cssmodules_ls.setup {}
c.pyright.setup {}
end
},
}

View file

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

View file

@ -24,7 +24,7 @@ require('util').keymaps({
end,
desc = "Find Scratches",
},
["<leader>s"] = { "<Nop>", desc = " Scratch File" },
["<leader>s"] = { "<Nop>", desc = "Scratch File" },
["<leader>ss"] = { function() scratch ".txt" end, desc = "New text scratch file" },
["<leader>sn"] = { function() scratch ".json" end, desc = "New json scratch file" },
["<leader>sq"] = { function() scratch ".sql" end, desc = "New sql scratch file" },