python configs i think

master
Jordan Orelli 2 months ago
parent f5d1901de7
commit a9c4046bc2

@ -3,13 +3,13 @@ local has_pyright = nil
-- These are files that are typically located in the root directory of a Python -- These are files that are typically located in the root directory of a Python
-- project -- project
local root_files = { local root_files = {
'pyproject.toml', 'pyrightconfig.json',
'.git',
'setup.py', 'setup.py',
'setup.cfg', 'setup.cfg',
'requirements.txt', 'requirements.txt',
'Pipfile', 'Pipfile',
'pyrightconfig.json', 'pyproject.toml',
'.git',
} }
local buf = vim.api.nvim_get_current_buf() local buf = vim.api.nvim_get_current_buf()
@ -17,9 +17,11 @@ local buf = vim.api.nvim_get_current_buf()
local root_dir = vim.fs.root(buf, root_files) local root_dir = vim.fs.root(buf, root_files)
local git_dir = vim.fs.root(buf, {'.git'}) local git_dir = vim.fs.root(buf, {'.git'})
local pyright_cmd = {'pyright-langserver', '--stdio'}
local pyright = vim.lsp.start({ local pyright = vim.lsp.start({
name = 'pyright', name = 'pyright',
cmd = {'pyright-langserver', '--stdio'}, cmd = pyright_cmd,
filetypes = { 'python' }, filetypes = { 'python' },
root_dir = root_dir, root_dir = root_dir,
single_file_support = true, single_file_support = true,

@ -1,2 +1,15 @@
-- yay local etc = require("etc")
-- local rustup_home = os.getenv('RUSTUP_HOME') or util.path.join(user_home, '.rustup')
local buf = vim.api.nvim_get_current_buf()
local rustup_dir = os.getenv('RUSTUP_HOME') or vim.env.HOME .. '.rustup'
if etc.has_executable("rust-analyzer") then
local rust_analyzer = vim.lsp.start({
name = 'rust-analyzer',
cmd = { 'rust-analyzer' },
filetypes = { 'rust' },
single_file_support = true,
root_dir = vim.fs.root(buf, {'Cargo.toml', '.git'}),
})
vim.lsp.buf_attach_client(buf, rust_analyzer)
end

@ -1,130 +1,134 @@
local signature = require("lsp_signature") local signature, _ = pcall(function()
return require("lsp_signature")
end);
signature.setup({ if signature then
-- set to true to enable debug logging signature.setup({
debug = false, -- set to true to enable debug logging
debug = false,
-- log dir when debug is on -- log dir when debug is on
-- default is ~/.cache/nvim/lsp_signature.log -- default is ~/.cache/nvim/lsp_signature.log
log_path = vim.fn.stdpath("cache") .. "/lsp_signature.log", log_path = vim.fn.stdpath("cache") .. "/lsp_signature.log",
-- show debug line number -- show debug line number
verbose = false, verbose = false,
-- This is mandatory, otherwise border config won't get registered. -- This is mandatory, otherwise border config won't get registered.
-- If you want to hook lspsaga or other signature handler, pls set to false -- If you want to hook lspsaga or other signature handler, pls set to false
bind = true, bind = true,
-- will show two lines of comment/doc(if there are more than two lines in doc, will be truncated); -- will show two lines of comment/doc(if there are more than two lines in doc, will be truncated);
-- set to 0 if you DO NOT want any API comments be shown -- set to 0 if you DO NOT want any API comments be shown
-- This setting only take effect in insert mode, it does not affect signature help in normal -- This setting only take effect in insert mode, it does not affect signature help in normal
-- mode, 10 by default -- mode, 10 by default
doc_lines = 0, doc_lines = 0,
-- max height of signature floating_window -- max height of signature floating_window
max_height = 12, max_height = 12,
-- max_width of signature floating_window, line will be wrapped if exceed max_width -- max_width of signature floating_window, line will be wrapped if exceed max_width
-- the value need >= 40 -- the value need >= 40
max_width = 80, max_width = 80,
-- allow doc/signature text wrap inside floating_window, useful if your lsp return doc/sig is too long -- allow doc/signature text wrap inside floating_window, useful if your lsp return doc/sig is too long
wrap = true, wrap = true,
-- show hint in a floating window, set to false for virtual text only mode -- show hint in a floating window, set to false for virtual text only mode
floating_window = true, floating_window = true,
-- try to place the floating above the current line when possible Note: -- try to place the floating above the current line when possible Note:
-- will set to true when fully tested, set to false will use whichever side has more space -- will set to true when fully tested, set to false will use whichever side has more space
-- this setting will be helpful if you do not want the PUM and floating win overlap -- this setting will be helpful if you do not want the PUM and floating win overlap
floating_window_above_cur_line = true, floating_window_above_cur_line = true,
-- adjust float windows x position. -- adjust float windows x position.
-- can be either a number or function -- can be either a number or function
floating_window_off_x = -8, floating_window_off_x = 0,
-- adjust float windows y position. e.g -2 move window up 2 lines; 2 move down 2 lines -- adjust float windows y position. e.g -2 move window up 2 lines; 2 move down 2 lines
-- can be either number or function, see examples -- can be either number or function, see examples
floating_window_off_y = 14, floating_window_off_y = 0,
-- close floating window after ms when laster parameter is entered -- close floating window after ms when laster parameter is entered
close_timeout = 4000, close_timeout = 4000,
-- set to true, the floating window will not auto-close until finish all parameters -- set to true, the floating window will not auto-close until finish all parameters
fix_pos = false, fix_pos = false,
-- virtual hint enable -- virtual hint enable
hint_enable = true, hint_enable = true,
-- Panda for parameter, NOTE: for the terminal not support emoji, might crash -- Panda for parameter, NOTE: for the terminal not support emoji, might crash
-- or, provide a table with 3 icons -- or, provide a table with 3 icons
-- hint_prefix = { -- hint_prefix = {
-- above = "↙ ", -- when the hint is on the line above the current line -- above = "↙ ", -- when the hint is on the line above the current line
-- current = "← ", -- when the hint is on the same line -- current = "← ", -- when the hint is on the same line
-- below = "↖ " -- when the hint is on the line below the current line -- below = "↖ " -- when the hint is on the line below the current line
-- } -- }
hint_prefix = "🐼 ", hint_prefix = "🐼 ",
hint_scheme = "String", hint_scheme = "String",
-- should the hint be inline(nvim 0.10 only)? default false -- should the hint be inline(nvim 0.10 only)? default false
-- return true | 'inline' to show hint inline, return 'eol' to show hint at end of line, return false to disable -- return true | 'inline' to show hint inline, return 'eol' to show hint at end of line, return false to disable
-- return 'right_align' to display hint right aligned in the current line -- return 'right_align' to display hint right aligned in the current line
hint_inline = function() return false end, hint_inline = function() return false end,
-- how your parameter will be highlight -- how your parameter will be highlight
hi_parameter = "LspSignatureActiveParameter", hi_parameter = "LspSignatureActiveParameter",
handler_opts = { handler_opts = {
-- double, rounded, single, shadow, none, or a table of borders -- double, rounded, single, shadow, none, or a table of borders
border = "rounded" border = "rounded"
}, },
-- sometime show signature on new line or in middle of parameter can be confusing, set it to false for #58 -- sometime show signature on new line or in middle of parameter can be confusing, set it to false for #58
always_trigger = false, always_trigger = false,
-- autoclose signature float win after x sec, disabled if nil. -- autoclose signature float win after x sec, disabled if nil.
auto_close_after = nil, auto_close_after = nil,
-- Array of extra characters that will trigger signature completion, e.g., {"(", ","} -- Array of extra characters that will trigger signature completion, e.g., {"(", ","}
extra_trigger_chars = {}, extra_trigger_chars = {},
-- by default it will be on top of all floating windows, set to <= 50 send it to bottom -- by default it will be on top of all floating windows, set to <= 50 send it to bottom
zindex = 200, zindex = 200,
-- character to pad on left and right of signature can be ' ', or '|' etc -- character to pad on left and right of signature can be ' ', or '|' etc
padding = '', padding = '',
-- disabled by default, allow floating win transparent value 1~100 -- disabled by default, allow floating win transparent value 1~100
transparency = nil, transparency = nil,
-- if you using shadow as border use this set the opacity -- if you using shadow as border use this set the opacity
shadow_blend = 36, shadow_blend = 36,
-- if you using shadow as border use this set the color e.g. 'Green' or '#121315' -- if you using shadow as border use this set the color e.g. 'Green' or '#121315'
shadow_guibg = 'Black', shadow_guibg = 'Black',
-- default timer check interval set to lower value if you want to reduce latency -- default timer check interval set to lower value if you want to reduce latency
timer_interval = 50, timer_interval = 50,
-- toggle signature on and off in insert mode, e.g. toggle_key = '<M-x>' -- toggle signature on and off in insert mode, e.g. toggle_key = '<M-x>'
toggle_key = nil, toggle_key = nil,
-- true: toggle floating_windows: true|false setting after toggle key pressed -- true: toggle floating_windows: true|false setting after toggle key pressed
-- false: floating_windows setup will not change, toggle_key will pop up signature helper, but signature -- false: floating_windows setup will not change, toggle_key will pop up signature helper, but signature
-- may not popup when typing depends on floating_window setting -- may not popup when typing depends on floating_window setting
toggle_key_flip_floatwin_setting = false, toggle_key_flip_floatwin_setting = false,
-- cycle to next signature, e.g. '<M-n>' function overloading -- cycle to next signature, e.g. '<M-n>' function overloading
select_signature_key = nil, select_signature_key = nil,
-- imap, use nvim_set_current_win to move cursor between current win and floating window -- imap, use nvim_set_current_win to move cursor between current win and floating window
-- e.g. move_cursor_key = '<M-p>', -- e.g. move_cursor_key = '<M-p>',
-- once moved to floating window, you can use <M-d>, <M-u> to move cursor up and down -- once moved to floating window, you can use <M-d>, <M-u> to move cursor up and down
move_cursor_key = nil, move_cursor_key = nil,
-- relate to move_cursor_key; the keymaps inside floating window -- relate to move_cursor_key; the keymaps inside floating window
-- e.g. keymaps = { 'j', '<C-o>j' } this map j to <C-o>j in floating window -- e.g. keymaps = { 'j', '<C-o>j' } this map j to <C-o>j in floating window
-- <M-d> and <M-u> are default keymaps to move cursor up and down -- <M-d> and <M-u> are default keymaps to move cursor up and down
keymaps = {} keymaps = {}
}) })
end

@ -15,3 +15,5 @@ telescope.setup({
} }
}, },
}) })
-- builtin.lsp_references

@ -1,6 +1,7 @@
local M = {} local M = {}
local telescope = require("telescope.builtin") local telescope = require("telescope.builtin")
local path = require("etc.path")
-- cache directory checks for great speed -- cache directory checks for great speed
local work_tree_lookup_cache = {} local work_tree_lookup_cache = {}
@ -28,4 +29,8 @@ M.project_files = function()
end end
end end
M.has_executable = function(exe_name)
return vim.fn.executable(exe_name) == 1
end
return M return M

@ -5,6 +5,8 @@ vim.keymap.set('n', '<F2>', telescope.diagnostics, {})
vim.keymap.set('n', '<leader>o', telescope.buffers, {}) vim.keymap.set('n', '<leader>o', telescope.buffers, {})
vim.keymap.set('n', '<C-k>', vim.cmd.bnext, {}) vim.keymap.set('n', '<C-k>', vim.cmd.bnext, {})
vim.keymap.set('n', '<C-j>', vim.cmd.bprev, {}) vim.keymap.set('n', '<C-j>', vim.cmd.bprev, {})
-- vim.keymap.set('n', '<leader>r', vim.lsp.buf.references, {})
vim.keymap.set('n', '<leader>r', telescope.lsp_references, {})
-- vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv") -- vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
-- vim.keymap.set("v", "K", ":m '>-2<CR>gv=gv") -- vim.keymap.set("v", "K", ":m '>-2<CR>gv=gv")

@ -52,7 +52,7 @@ function load_plugins(use)
"lewis6991/gitsigns.nvim" "lewis6991/gitsigns.nvim"
} }
use { "ray-x/lsp_signature.nvim" } -- use { "ray-x/lsp_signature.nvim" }
use { "ervandew/supertab" } use { "ervandew/supertab" }
-- a file browser -- a file browser

Loading…
Cancel
Save